Nodejs-pubsub: Google PubSub Import Error

Created on 26 May 2020  路  9Comments  路  Source: googleapis/nodejs-pubsub

Environment details
OS: Windows
Node.js version: v13.10.1
npm version: 6.13.7
Google Cloud SDK 293.0.0
bq 2.0.57
core 2020.05.15
gsutil 4.50

Steps to reproduce
Importing @google-cloud/pubsub results in what looks like a combination of bootstrap and GRPC errors. I have included the stack trace and package.json for reference. The error appears to be an issue from google gax and grpc status codes (undefined).

stack trace:
errorStackTrace.txt

package.json :
package.txt

Steps I Have Taken That Did Not Fix
-reinstalled Google Pub Sub through npm
-removed all node-modules, cleared npm cache, and ran npm install
-installed GRPC, attempted to import GRPC and use it to initialize PubSub
-reinstalled Firebase through npm
*deleted package-lock before reinstalling through npm

Reference
This issue occurs just by importing PubSub, no initialization of PubSub or actual client-library code written. If I remove the import, my application runs and does not crash. I have attempted to import in two different ways and get the same result:

const {PubSub} = require('@google-cloud/pubsub'); //from the google docs
and
import PubSub from '@google-cloud/pubsub'

For reference, my application runs on React and heavily uses Firebase for real time data syncing. I am looking to use Google Pub Sub to communicate notifications to the main console of the application, and notifications will be published by many different sub-components throughout the application.

pubsub feature request web

Most helpful comment

I somehow totally missed the browser connection there. After a bit of internal discussion, we don't actually support using this library from a browser, but it's an aspiration. It looks like what's happening here is that it's failing to load protos via gax, which is pretty understandable. (I think they are dynamically require()'d in.) So I'm going to flip this from a question to a feature request for working webpack support.

All 9 comments

I've got the same issue with the following npm/node:

npm --version
6.14.4

node --version
v10.20.1

Environment is WSL 2.0, Ubuntu on Windows 10

@oaguilar5 @qstrahl Thanks for the report. There are some TypeScript incompatibilities that were introduced when we moved up to the latest minor in Pub/Sub 2.0.0. I wonder if there's something going on there, but I'll try to look at this after fixing that other issue.

@oaguilar5 just to make this crystal clear - you're trying to run this through webpack and run it in the browser, right?

@JustinBeckwith correct, tried both import and require

any updates on this?

Nope

I somehow totally missed the browser connection there. After a bit of internal discussion, we don't actually support using this library from a browser, but it's an aspiration. It looks like what's happening here is that it's failing to load protos via gax, which is pretty understandable. (I think they are dynamically require()'d in.) So I'm going to flip this from a question to a feature request for working webpack support.

@feywind thank you! This would be fantastic to use on a browser to enable communication of components that are not worthy of being saved to a database (i.e. user field focus on a shared form). At the moment we are blocked on this aspect of our app - may I ask on a ballpark level how feasible this feature request will be to process/implement? (A month, this year, next year, etc) depending on feasibility, we may need to look at alternate solutions but would like to use google pub sub since our app is built entirely within the google engine. Thanks in advance!

I haven't dug into it in depth, but I _think_ the dynamic loading issue is in gax. And we may still be referencing gRPC C++ by default, which is not going to work for a browser context. There may be other issues, too, it's just not a tested use case right now.

That web label Justin added is for us to track these kinds of requests though, to make a case for spending some time on doing it. I'm afraid someone higher up than me would need to comment on the if/when 馃槄

Was this page helpful?
0 / 5 - 0 ratings

Related issues

steffiisawesome picture steffiisawesome  路  8Comments

ThomWright picture ThomWright  路  6Comments

vongohren picture vongohren  路  3Comments

MPNull picture MPNull  路  5Comments

colmsnowplow picture colmsnowplow  路  8Comments