apollo-engine-reporting-protobuf0.4.012.10.0apollo-engine-reporting-protobuf modifies the behavior of 3rd party package protobufjs by removing its support for Long:
This is an issue for other packages depending on protobufjs, in my case @google-cloud/logging.
Whenever I try to send logs via Google Cloud's lib I get the following exception:
(node:66122) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'fromNumber' of undefined
at Field.resolve (/Volumes/Double/graphql-server/node_modules/protobufjs/src/field.js:289:38)
at Type.setup (/Volumes/Double/graphql-server/node_modules/protobufjs/src/type.js:435:41)
at Type.encode_setup [as encode] (/Volumes/Double/graphql-server/node_modules/protobufjs/src/type.js:485:17)
at Type.LogEntry$encode [as encode] (eval at Codegen (/Volumes/Double/graphql-server/node_modules/@protobufjs/codegen/index.js:50:33), <anonymous>:19:12)
at Type.encode_setup [as encode] (/Volumes/Double/graphql-server/node_modules/protobufjs/src/type.js:485:25)
at BundleDescriptor.getByteLength [as byteLengthFunction] (/Volumes/Double/graphql-server/node_modules/google-gax/src/grpc.ts:322:22)
at /Volumes/Double/graphql-server/node_modules/google-gax/src/bundlingCalls/bundleExecutor.ts:139:40
at Array.forEach (<anonymous>)
at BundleExecutor.schedule (/Volumes/Double/graphql-server/node_modules/google-gax/src/bundlingCalls/bundleExecutor.ts:138:18)
at /Volumes/Double/graphql-server/node_modules/google-gax/src/bundlingCalls/bundleApiCaller.ts:77:20
...which makes sense, since Longs are not supported anymore by the lib.
It seems very "aggressive" to change a global library potentially used by other dependencies.
I too am experiencing problems with my application's functionality with this tampering of the protobufjs library.
What I have done as a temporary measure to prevent this undefined assignment to Long is to put the following snippet before importing apollo-server.
const protobufJS = require('protobufjs/minimal');
const utilProxy = new Proxy(protobufJS.util, {
set(obj, prop, value) {
if (prop !== "Long") {
obj[prop] = value;
}
}
});
protobufJS.util = utilProxy;
Hopefully the Apollo team finds a better means of dealing with this soon.
Thanks for reporting this @pierre-elie I just hit this recently, too, trying to use @google-cloud/logging-winston in an apollo server. I originally thought it was some bug in Google's code, but now this makes more sense. Thanks for the workaround for now @allenhartwig
Thank you all for the report!
This is resolved in the latest release:
https://github.com/apollographql/apollo-server/commit/8d065d8b8b7f35f814695e74f5c685b7d68d5e00
Please update your apollo-server-* and @apollo/gateway versions to latest!
Most helpful comment
I too am experiencing problems with my application's functionality with this tampering of the protobufjs library.
What I have done as a temporary measure to prevent this
undefinedassignment toLongis to put the following snippet before importingapollo-server.Hopefully the Apollo team finds a better means of dealing with this soon.