Error Handling in the Subscription MessageHandler
See original GitHub issueThe Subscription extension of the EventEmitter class appears to ignore errors that happen within the messageHandler. The EventEmitter listener for ‘error’ and ‘uncaughtException’ on Subscription seems to be eaten or ignored. To test this:
const messageHandler = (message) => {
throw new Error('always an error');
};
const errorHandler = (err) => {
logger.error('caught an error, continuing on');
};
subscription.on('message', messageHandler);
subscription.on('error', errorHandler);
‘error’ doesn’t catch and the app crashes, we found the only way around this is to emit the error to the app instead of throwing, then handle it at the app layer, but that is undesirable for being able to handle the errors gracefully from our pubsub codebase and is really hacky passing the app down to our subscription service.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Spring integration JDBCMessageHandler error handling ...
My intent is that any exceptions or errors will be caught and rerouted from this subflow level, where the message is complete, to...
Read more >Subscribe with error listener | Cloud Pub/Sub Documentation
Handles errors when subscribing throws an error. ... Setup an error handler for the subscription session .then([](future<google::cloud::Status> f) {
Read more >Error Handling - Spring
Spring Integration supports error handling for its components by publishing errors to a message channel. Specifically, the Exception becomes the ...
Read more >Service Bus messaging exceptions - Azure - Microsoft Learn
This article provides a list of Azure Service Bus messaging exceptions and suggested actions to taken when the exception occurs.
Read more >5. Error Handling — Advanced Message Processing System ...
When using asynchronous message processing, exceptions thrown form the message handler are silently absorbed by the AMPS C++ client by default. The AMPS...
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
I think if you use the scope of the message handler, you can emit right there and your subscriber error handler will catch it. So, something like:
Or, you can just emit it right on the subscription instance,
subscription.emit('error', new Error('Message'))
.This seems pretty specific to @stoked10’s implementation, so I don’t think we need to add any samples for it.