Pubsub emulator with v1 doesn't work
See original GitHub issueEnvironment details
- OS: MacOS
- Node.js version: 12
- npm version: Latest yarn 1.x
@google-cloud/pubsub
version: Latest
Steps to reproduce
Using the synchronous pull example, the PusSub emulator doesn’t seem to be working. It’s as the env variable PUBSUB_EMULATOR_HOST
is being ignored.
Also,
with the default emulator local host (localhost:8085
), if I do:
const subClient = new v1.SubscriberClient({
apiEndpoint: 'localhost:8085',
});
I am getting the error:
Error: Failed to parse target localhost:8085:443
at Function.getDefaultAuthority (/node_modules/@grpc/grpc-js/src/resolver-dns.ts:313:11)
at Object.getDefaultAuthority (/node_modules/@grpc/grpc-js/src/resolver.ts:134:28)
at new ChannelImplementation (/node_modules/@grpc/grpc-js/src/channel.ts:199:31)
at new Client (/node_modules/@grpc/grpc-js/src/client.ts:82:30)
at new ServiceClientImpl (/node_modules/@grpc/grpc-js/src/make-client.ts:104:3)
at GrpcClient.createStub (/node_modules/google-gax/src/grpc.ts:306:18)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Issue Analytics
- State:
- Created 4 years ago
- Comments:14
Top Results From Across the Web
Testing apps locally with the emulator | Cloud Pub/Sub ...
To develop and test your application locally, you can use the Pub/Sub emulator, which provides local emulation of the production Pub/Sub service. You...
Read more >Push isn't working with pubsub emulator - Google Groups
Is there something I'm doing wrong or is it just that the emulator doesn't work with push subscriptions? Steeve's profile photo. Steeve.
Read more >Can't reach GCP PubSub Emulator - Stack Overflow
I have setup the PubSub emulator to run a Python script locally pointing to it. The emulator is run following the tutorial and...
Read more >Install, configure and integrate Local Emulator Suite - Firebase
The Firebase Local Emulator Suite can be installed and configured for different prototype and test environments, anything from one-off prototyping sessions ...
Read more >The pubsub emulator doesn't deliver to push endpoints in the ...
Hi James, This is a known bug in the Pub/Sub emulator, the fix for which should come out in the next Cloud SDK...
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
@feywind this is also preventing my team from working with the Pub/Sub emulator locally, which makes development difficult. The workarounds proposed in https://github.com/googleapis/nodejs-pubsub/issues/346 don’t work.
Here are some ways to work around this, based on my testing:
The simplest, but probably also the most prone to breakage over time (these aren’t the same types, but they do technically contain the same things):
That will actually pick up the emulator environment variable in the normal way, since it’s just using the PubSub class’ init.
The specific members could be copied like so, to be a bit less breakable:
You could also manually init the options, though I understand that wasn’t working for some:
(And of course requires app logic, which may not be great.)
I also feel obligated to note that digging into PubSub.options isn’t really a public interface, so that could change whenever. I think probably the good long term solution for this is still the unified environment variables plus gapic client support for it. If it looks like the timeline is long on that, then I suppose another option would be to expose a “give me a client” method on PubSub.
Let me know if anything in there seems like it works, or if you have any ideas about making an interface that works better for you.