Project ID not set when using emulator (MissingProjectIdError)
See original GitHub issueEnvironment details
- OS: macOS 10.13.6
- Node.js version: 10.15.3
- npm version: 6.4.1
@google-cloud/pubsub
version: 0.28.1
Steps to reproduce
export PUBSUB_EMULATOR_HOST="..."
export GOOGLE_CLOUD_PROJECT="..."
const {PubSub} = require('@google-cloud/pubsub')
const pubsub = new PubSub()
const [topics] = await pubsub.getTopics()
Expected
List of topics for the project specified in the environment variable for the local emulated Pub/Sub.
Actual
node_modules/@google-cloud/projectify/build/src/index.js:45
throw new MissingProjectIdError();
^
Error: Sorry, we cannot connect to Cloud Services without a project
ID. You may specify one with an environment variable named
"GOOGLE_CLOUD_PROJECT".
at replaceProjectIdToken (node_modules/@google-cloud/projectify/build/src/index.js:45:19)
at Object.replaceProjectIdToken (node_modules/@google-cloud/projectify/build/src/index.js:38:30)
at getClient_ (node_modules/@google-cloud/pubsub/build/src/pubsub.js:644:36)
at PubSub.getClient_ (node_modules/@google-cloud/pubsub/build/src/pubsub.js:623:9)
at PubSub.request (node_modules/@google-cloud/pubsub/build/src/pubsub.js:638:14)
at PubSub.getTopics [as getTopics_] (node_modules/@google-cloud/pubsub/build/src/pubsub.js:567:14)
at makeRequest (node_modules/@google-cloud/paginator/build/src/index.js:240:13)
at Object.makeRequest (node_modules/@google-cloud/paginator/build/src/index.js:52:27)
at Transform.stream.once (node_modules/@google-cloud/paginator/build/src/index.js:237:21)
at Object.onceWrapper (events.js:277:13)
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
`firebase serve --only functions` - Error: Sorry, we cannot ...
Commenting out the throw in /home/saiy2k/projects/ionic/grcloud/ ... the error causes no ill effect to the emulator that I can gather.
Read more >Project ID is Required Error in 6.0a1 - Google Groups
... A project ID is required for this service but could not be determined from the builder or the environment. Please set a...
Read more >Working with the Google Datastore emulator - Sense Codons
In "google-cloud-gui", you set the project ID in the UI when you hit the "+" button to create a new project. In "dsui",...
Read more >google-datastore-emulator - npm
This variable is datastore project Id. storeOnDisk (boolean), false, The datastore either persists the entities on disk or not. dataDir (string) ...
Read more >Install, configure and integrate Local Emulator Suite - Firebase
Project ID configuration. Depending on how you invoke emulators, you may run multiple instances of an emulator using different Firebase project IDs or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
new PubSub({ projectId: process.env.GOOGLE_CLOUD_PROJECT })
is an obvious workaround.Still, would be nice to fix the bug. For example, I wanted to use /samples as a quick CLI tool to publish some messages into my local PubSub. Couldn’t do it without first modifying the code.
@osrecki I’m going ahead and closing this issue, since it sounds like you’re unblocked.
I’ve gone ahead and opened this issue, since it does sound like this is a confusing sharp corner on the library.
@guyiluz my guess is that
GOOGLE_CLOUD_PROJECT
might not be populated in your case, try addingconsole.info(process.env.GOOGLE_CLOUD_PROJECT)
just before executing your library.If you’re continuing to bump into problems, please go ahead and open a new issue with a reproduction.