0
votes

I am trying to run my Firebase functions locally through the emulator. I have built a architecture where chains of processes are invoked by PubSub events. When trying to invoke these events, the emulator logs give me this:

Sorry, we cannot connect to Cloud Services without a project ID. You may specify one with an environment variable named "GOOGLE_CLOUD_PROJECT".

I am running the emulators with --project {projectID}. Also I am constructing my PubSub events like this:

const pubsub = new PubSub({ projectId: getRealtimeDatabase().app.options.projectId })

I am using package "@google-cloud/pubsub": "^0.22.2", and I am importing PubSub like import { PubSub } from '@google-cloud/pubsub';

What do I have to do to make PubSub invoke new events? Thanks!

1

1 Answers

0
votes

Turned out getRealtimeDatabase().app.options.projectId was undefined. I retrieved my projectId elsewhere. With the correct projectId, the code above works.