GoogleCloudPlatform / node-red-contrib-google-cloud

Node-RED nodes for Google Cloud Platform
Apache License 2.0
90 stars 57 forks source link

Node-Red crashes with [error] ReferenceError: OnError is not defined #113

Open gilmiz opened 2 years ago

gilmiz commented 2 years ago

Node-Red crashes when using the PubSub node to publish and subscribe for messages

Terminal message is:

[error] ReferenceError: OnError is not defined
at Subscription.OnClose (/home/nnn/.node-red/node_modules/node-red-contrib-google-cloud/pubsub-in.js:110:54) at Subscription.emit (node:events:520:28) at Subscriber. (/home/nnn/.node-red/node_modules/@google-cloud/pubsub/src/subscription.ts:320:32) at Subscriber.emit (node:events:520:28) at ModAckQueue.flush (/home/nnn/.node-red/node_modules/@google-cloud/pubsub/src/message-queues.ts:144:24)

Testing with a simple flow like image image

The problem appeared sometime within the last month.

I've tried reinstalling, without any change.

Did anyone else experience the same?

/Gilad

gylim78 commented 2 years ago

Hi there,

I got the same error. Maybe the same thing happened to you.

I was simulating an internet connection break by turning off the wifi on my laptop and this error appeared about 5 mins after that. This is kind of a problem for me as I am deploying in a Raspberry pi and the internet connection is a mobile connection so I do expect the internet to go down from time to time.

If anyone has solved this issue or has any suggestions, it would be greatly appreciated.

kolban-google commented 2 years ago

Howdy chums ... am on it today!! Thanks for raising the issue. Stay tuned.

gylim78 commented 2 years ago

I was actually looking through the code. The issue should be just that the function OnError does not exist. It should be OnClose instead.

I believe that it should be subscription.removeListener('error', OnClose);

kolban-google commented 2 years ago

Ty @gylim78 ... I made the change ... committed to GutHub, published to npm and refreshed at Node-RED

If you could check it out when you can, that would be appreciated.