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
BREAKING CHANGE: awaitable queues #1641
Conversation
} | ||
|
||
function on (event, handler) { | ||
events[event].push(handler) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's quite an interesting way of handling both promises and the current API. Is the promise based API useful for any of the events besides drain
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's most useful for drain
, but i can see utility coming from unsaturated
, and making error
reject. I'm also happy making the interface uniform for all the event-style methods.
You can show the problem with this code (in node or browser without the require): const async = require('async');
let pushResult;
(async () => {
const q = async.queue(async (task) => {
throw new Error('Bad thing');
});
try {
pushResult = q.push({some: 'data'});
await pushResult;
console.log('Error not catched');
} catch (e) {
console.log('Error catched');
}
})();
setTimeout(() => {
console.log('exit');
console.log(pushResult);
}, 1000); |
- Fixes for latest version of async which introduced breaking change --> caolan/async#1641 - Removed ignore dep from .ncurc.json as all issues have been resolved - Following dependencies were updated: async 2.6.2 → 3.1.0 node-rdkafka 2.6.1 → 2.7.1 raw-body 2.4.0 → 2.4.1 sinon 7.2.4 → 7.4.2 tap-xunit 2.3.0 → 2.4.1 tape 4.10.1 → 4.11.0
### Dependency updates: - Fixes for the latest version of async which introduced a breaking change --> caolan/async#1641 - Removed ignore dependency list from .ncurc.json as all issues have been resolved - Following dependencies were updated: async 2.6.2 → 3.1.0 node-rdkafka 2.6.1 → 2.7.1 raw-body 2.4.0 → 2.4.1 sinon 7.2.4 → 7.4.2 tap-xunit 2.3.0 → 2.4.1 tape 4.10.1 → 4.11.0 ### Maintenance updates: - Replaced central-services-shared dep with central-service-logger - Migrated from istanbul to nyc - Moved unit tests to a test/unit folder to be consistent with other repos - Added editorconfig, eslintignore, & eslintrc for consistency with other repos
Closes #1586
This changes the queue API a bit, allowing queue events to be awaited, as well as the results for an individual task. You can now do: