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/Errors are not caught/handled in any queue items beyond the first. #6

Closed
EricByers opened this issue Nov 3, 2015 · 1 comment

Comments

@EricByers
Copy link
Contributor

Specifically in nodejs (v0.12.7). I'm using Q for promises, but I think the same will happen with others.

Some sample code:

var Q = require('q');
var Queue = require('promise-queue');
Queue.configure(function (handler) {
    var deferred = Q.defer();
    try {
        handler(deferred.resolve, deferred.reject, deferred.notify);
    } catch (e) {
        console.error(e);
        deferred.reject(e);
    }
    return deferred.promise;
});

var maxConcurrent = 1;
var maxQueue = Infinity;
var serialQueue = new Queue(maxConcurrent, maxQueue);

serialQueue.add(function() {
     throw new Error('error that is caught');
});

serialQueue.add(function() {
     throw new Error('error that is not caught');
});

My thought is that the first one works because the _dequeue is directly in the try/catch. However on subsequent calls when the _dequeue is called from the then/reject the scope changes and it's not in the try/catch block anymore.

I was going to take a stab at a PR, but not sure the best way of handling it or if it's even possible without changing the interface.

@azproduction
Copy link
Collaborator

Resolved in promise-queue@2.2.0

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

No branches or pull requests

2 participants