Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exceptions thrown in 'message' event go unnotticed #3

Closed
panickos opened this issue Aug 7, 2015 · 3 comments
Closed

Exceptions thrown in 'message' event go unnotticed #3

panickos opened this issue Aug 7, 2015 · 3 comments
Assignees

Comments

@panickos
Copy link

panickos commented Aug 7, 2015

While using the 'message' event to process an incoming message on a worker I noticed that the worker was throwing an 'error' event on every single message but I was not getting anything in the error object.

After many hours I realized that the problem was within one of my functions processing said messages, but I couldn't realize from where since the exception thrown what getting lost.

I'm not sure if this is something you should fix or if I should just encapsulate all my code within try {} catch {} blocks.

i.e:

inboundQueueWorker.on('message', function(message, next, msgid) {
        try {
            ...
            next();
        } catch (e) {
            next(e)
        }
    });

I'd be interested to hear your opinion on this.

@mpneuried
Copy link
Owner

Thanks for this information.
I'll check this and let you kown.

@mpneuried mpneuried self-assigned this Aug 26, 2015
@mpneuried mpneuried added the bug label Aug 26, 2015
mpneuried pushed a commit that referenced this issue Sep 2, 2015
…sing.

Added option `alwaysLogErrors` to prevent console logs if an error event handler was attached.
#3
@mpneuried
Copy link
Owner

I added some tests to check your problem.
Internally rsmq-worker wraps the message processing with a try-catch.
This is useful, because it keeps the worker running and processing messages even if a hard error was thrown.
But before version 0.3.7 a error appeared within the console/stderr-output.
Until the new 0.3.7 this log will be prevented if an error listener was attached or you set alwaysLogErrors = true.

In your case you described taht an error event was thrown, but without any content.
I couldn't reproduce this with the 2 new test cases. Can you help me with more details?

@panickos
Copy link
Author

I tried your tests and it is working great! Thanks!

I think I was using an older version of the code and I was not configuring it properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants