@google-cloud/pubsub version: 0.32.0const pubsub = new PubSub();
const data = JSON.stringify({ id: `foo`, operation: { name: `bar` } });
const dataBuffer = Buffer.from(data);
pubsub.topic(`projects/project-id/topics/xxx`).publish(dataBuffer).then(messageId => {
console.log(`Message ${messageId} published.`);
callback();
}).catch(err => {
console.error('ERROR:', err);
callback();
});
and error:
{
insertId: "000000-bd28418c-a3e9-4001-beca-235601190e6d"
receiveTimestamp: "2019-09-12T14:35:01.511527849Z"
severity: "ERROR"
textPayload: "ERROR: TypeError: Cannot read property 'length' of undefined
at Root.load (/srv/node_modules/protobufjs/src/root.js:192:44)
at Root.loadSync (/srv/node_modules/protobufjs/src/root.js:235:17)
at Object.loadSync (/srv/node_modules/@grpc/proto-loader/build/src/index.js:230:27)
at GrpcClient.loadFromProto (/srv/node_modules/google-gax/build/src/grpc.js:118:44)
at GrpcClient.loadProto (/srv/node_modules/google-gax/build/src/grpc.js:145:21)
at new PublisherClient (/srv/node_modules/@google-cloud/pubsub/build/src/v1/publisher_client.js:121:28)
at PubSub.getClientAsync_ (/srv/node_modules/@google-cloud/pubsub/build/src/pubsub.js:633:25)
at <anonymous>"
timestamp: "2019-09-12T14:35:00.812Z"
}
With 0.31.1 all works good.
馃憢 @avokhmin thanks for reporting this! We've actually been seeing the same issue in a few of our other clients (https://github.com/googleapis/nodejs-text-to-speech/issues/266, https://github.com/googleapis/nodejs-scheduler/issues/131).
@alexander-fenster just an FYI
Yeah, seems like there is some weird usecase where undefined gets all the way down to protobufjs. I'm trying to understand what's going on.
@avokhmin Can I bother you installing the version of this library with some extra logging and pasting the output here? Just do
npm install googleapis/nodejs-pubsub#debug
(it will install the library right from my GitHub branch)
Thank you for helping us fix it!
I have the same problem. Here is console log after install googleapis/nodejs-pubsub#debug.
=== Debug information ===
opts: {"credentials":{-----not shown here----,"projectId":"xxxxxx"}
global.isBrowser: undefined
nodejsProtoPath: /Users/pphetra/projects/horizon/new-horizons-server/functions/node_modules/@google-cloud/pubsub/build/protos/protos.json
opts.fallback: undefined
loadProto arg: /Users/pphetra/projects/horizon/new-horizons-server/functions/node_modules/@google-cloud/pubsub/build/protos/protos.json
=== End of debug information ===
/Users/pphetra/projects/horizon/new-horizons-server/functions/node_modules/protobufjs/src/root.js:193
for (var i = 0, resolved; i < filename.length; ++i)
^
TypeError: Cannot read property 'length' of undefined
at Root.load (/Users/pphetra/projects/horizon/new-horizons-server/functions/node_modules/protobufjs/src/root.js:192:44)
at Root.loadSync (/Users/pphetra/projects/horizon/new-horizons-server/functions/node_modules/protobufjs/src/root.js:235:17)
at Object.loadSync (/Users/pphetra/projects/horizon/new-horizons-server/functions/node_modules/@grpc/proto-loader/build/src/index.js:230:27)
at GrpcClient.loadFromProto (/Users/pphetra/projects/horizon/new-horizons-server/functions/node_modules/google-gax/build/src/grpc.js:118:44)
at GrpcClient.loadProto (/Users/pphetra/projects/horizon/new-horizons-server/functions/node_modules/google-gax/build/src/grpc.js:145:21)
at new PublisherClient (/Users/pphetra/projects/horizon/new-horizons-server/functions/node_modules/@google-cloud/pubsub/build/src/v1/publisher_client.js:133:28)
at Object.<anonymous> (/Users/pphetra/projects/horizon/new-horizons-server/functions/x.js:2:13)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
Same problem here using @google-cloud/[email protected]
Seems to be an issue with using an older version of gax-nodejs.
Old gax versions don't allow loadProto to be used with a single parameter, passing undefined down to loadFromProto
https://github.com/googleapis/gax-nodejs/pull/543/commits/e570cfa975939daf8d51fcbb9296f0f6983eb2d3
Either PubSub needs to use the older version properly or update gax
@Draiken That's a great (and possible) explanation to why undefined gets there! PubSub depends on "google-gax": "^1.0.0" which must pull the latest 1.x version (and the change to allow single parameter got released in google-gax v1.2.0), but if you have a lockfile, it might explain everything.
To all folks affected by the issue: can you please make your code do npm ls and send the output here? Removing your package-lock.json and node_modules and reinstalling should also help then.
But why not - let me send a PR to bump the gax dependency to the latest one and we'll see if it helps you folks. Here we go: #740
Can you folks try installing @google-cloud/pubsub v0.32.1, double check that it pulled google-gax v1.5.2+, and let us know here if the problem is still there?
Thank you!
Can you folks try installing @google-cloud/pubsub v0.32.1, double check that it pulled google-gax v1.5.2+, and let us know here if the problem is still there?
Thanks, v0.32.1 works good for me 馃憤 馃檱
This fixed the issue for me too. Thanks
@Draiken awesome, thanks for stopping by to let us know!
I was facing this issue when trying to run my script on Google sheets. Is this a similar issue? https://github.com/mithunmanohar/woocommerce-orders-google-sheets-integration/issues/44
Having the same issue, I have double-checked everything.
Most helpful comment
Thanks,
v0.32.1works good for me 馃憤 馃檱