question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property 'length' of undefined

See original GitHub issue

Environment details

  • OS: Google Cloud Functions
  • Node.js version: 8
  • npm version:
  • @google-cloud/pubsub version: 0.32.0

Steps to reproduce

const 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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
avokhmincommented, Sep 16, 2019

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 👍 🙇

3reactions
jpreynatcommented, Sep 13, 2019

Same problem here using @google-cloud/pubsub@0.32.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read properties of undefined (reading 'length') - TrackJS
This message indicates that our code expects to have an object with a length property, but that object was not present. length is...
Read more >
TypeError: Cannot read property 'length' of Undefined in JS
The "Cannot read property 'length' of undefined" error occurs when accessing the length property on an undefined value. To solve the error, make...
Read more >
Typeerror: Cannot Read Property 'length' of Undefined
A typeerror length of undefined can indicate that the actual type of an operand is different from the expected type. This error can...
Read more >
[SOLVED] Cannot Read Property 'length' of Undefined in JS
To fix the “cannot read property 'length' of undefined” error, perform an undefined check on the variable before accessing the length property ......
Read more >
Cannot read property length of undefined - Stack Overflow
The error means that what ever element is returned by getElementById('WallSearch') , it does not have a value property. Every form field has...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found