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.

Getting error: not supported when using pubsub.publish or pubsub.create topic.

See original GitHub issue

Environment details

  • OS: macOS
  • Node.js version: v10.15.3
  • npm version: 6.4.1
  • @google-cloud/pubsub version: “^0.28.1”

Steps to reproduce

  1. Used the following code to publish to an existing topic with a key that works with pubsub in another app I used:
try {
    data = 'my_Data'
    const pubsub = new PubSub({
      projectId: config.gcloudProjectID,
      keyFilename: './pubSubKey.json',
    });
    const payload = JSON.stringify({ someData: data });
    const dataBuffer = Buffer.from(payload);
    const messageId = await pubsub.topic(config.topicName).publish(dataBuffer);
  } catch (err) {
    logError('Failed to publish pubsub with error: ', err);
    throw err;
  }

I used a similar setup as above in another project and it worked fine.

  1. I then get the following error:
Error: not supported
 at GoogleProtoFilesRoot.loadSync (/Users/dev/tool/node_modules/protobufjs/src/root.js:234:15)
at Object.loadSync (/Users/dev/tool/node_modules/protobufjs/src/index-light.js:69:17)
at GrpcClient.loadProtoLegacy (/Users/dev/tool/node_modules/google-gax/build/src/grpc.js:164:54)
at GrpcClient.loadProto (/Users/dev/tool/node_modules/google-gax/build/src/grpc.js:200:42)
at new PublisherClient (/Users/dev/tool/node_modules/@google-cloud/pubsub/build/src/v1/publisher_client.js:95:15)
at PubSub.getClient_ (/Users/dev/tool/node_modules/@google-cloud/pubsub/build/src/pubsub.js:620:25)
at PubSub.request (/Users/dev/tool/node_modules/@google-cloud/pubsub/build/src/pubsub.js:638:14)
at Publisher.publish_ (/Users/dev/tool/node_modules/@google-cloud/pubsub/build/src/publisher.js:141:20)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10) +0ms

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
Msarnaotcommented, Apr 17, 2019

@callmehiphop We were able to resolve this issue. Since we did server side rendering we had some of our node intertwined with libraries that set the “window” variable and stored data in it. By the time we required the google-cloud pubsub library, the window was set and util.isNode resolves to false. We moved the require that included our pubsub code to run before any libraries that set the window object, and this resolved the issue for us a s util.isNode is true by the time it runs.

1reaction
michelepatrassicommented, Dec 3, 2019

@hbk899 @danieldanielecki you can fix by adding process to your fake window in the server.ts file

win.process = process;

You can find more info in this article, with also other errors I encountered with Angular SSR + Firebase

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting | Cloud Pub/Sub Documentation
Learn about troubleshooting steps that you might find helpful if you run into problems using Pub/Sub. Cannot create a subscription.
Read more >
Topic is created on cloud pub/sub but unable to create watch ...
If gmail is not granted the access to publish the message to Pubsub topic, watch request wont be created. Try API explorer to...
Read more >
Push isn't working with pubsub emulator - Google Groups
Hello! I'm trying to test locally withe the emulator which works fine for create topics/subscriptions, publishing and receiving. But I get ...
Read more >
pubsub - Go Packages
Google Cloud Pub/Sub messages are published to topics. Topics may be created using the pubsub package like so: topic, err := pubsubClient.
Read more >
@google-cloud/pubsub - npm
Cloud Pub/Sub Client Library for Node.js. Latest version: 3.1.1, last published: 6 days ago. Start using @google-cloud/pubsub in your ...
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