Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix(grpc): ensure that protobuf has Long support
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed Nov 14, 2019
1 parent d5f543a commit 810c343
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions renderer/workers/grpc.worker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
/* eslint-disable no-restricted-globals */

import { expose } from 'comlinkjs'
import * as Protobuf from 'protobufjs'
import Long from 'long'
import ZapGrpc from '@zap/services/grpc/grpc'

// Protobuf assumes that long.js is either available on the global scope or available to be required. However, when
// used from the context of one of our web workers neither of these assumptions is true. In order to ensure that Long
// support is available in protobuf we manually configure protobuf here, before it is used.
//
// See https://github.com/protobufjs/protobuf.js#browserify-integration
//
// This ensures that large numbers (such as those returned from chan_id props) can be properly handled without rounding.
Protobuf.util.Long = Long
Protobuf.configure()

expose(ZapGrpc, self)

0 comments on commit 810c343

Please sign in to comment.