Closed
Description
What do we imagine is the correct context when an unhandledrejection
is triggered? Given:
const ctx = new AsyncContext();
ctx.run("reg", () => {
addEventLitener('unhandledrejection', () => {
// ???
console.log(ctx.getStore());
});
})
let reject;
ctx.run("init", () => {
new Promise((_, rej) => {
reject = rej;
});
});
ctx.run("call", () => reject('boom'));
Our options include:
reg
, which is the context at the time of theunhandledrejection
's handler's registrationinit
, which is the context at the time of the promise's creationcall
, which is the context at the time of the promise's rejectionundefined
, which is the context at the timeunhandledrejection
handler is called
Also relevant, the call-time choice allows does not prevent you from using init-time behavior, you just need to wrap
your reject
:
let reject;
ctx.run(123, () => {
new Promise((_, rej) => {
reject = AsyncContext.wrap(rej);
});
});
ctx.run(321, () => reject('boom'));
Metadata
Metadata
Assignees
Labels
No labels