Having complex systems with various variables could result in leaking unintended values to subsystems. It might be reasonable to have something like AsyncContext.sandbox(() => {... }) which reset's all the state, preventing parents to interfere.
const asyncVar = new AsyncContext.Variable();
// Sets the current value to 'top', and executes the `main` function.
asyncVar.run("top", main);
function main() {
AsyncContext.sandbox(() => {
console.log(asyncVar.get()); // => undefined
});
}
Having complex systems with various variables could result in leaking unintended values to subsystems. It might be reasonable to have something like
AsyncContext.sandbox(() => {... })which reset's all the state, preventing parents to interfere.