-
Notifications
You must be signed in to change notification settings - Fork 78
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
How to deal with ambgious contexts for promise then callbacks #143
Comments
@ofrobots said here in reference to this async context visualization
/cc @mrkmarron . Mark & I discussed this yesterday. In DLS paper, the claim was (somewhere in there, Mark can point at exact location?) that if you chain onto an already resolved promise, then it's "causal context" is the same as it's "linking context", which is what the graph shows. I'll let @mrkmarron chime in on details of why this is. I think what you're getting at is you want to know the context that resolved the promise (effectively, the ability to traverse contexts of the promise chain). I think to achieve this, in the DAG you would have I agree with this. @mrkmarron? |
Hi Mike, yes I agree with your comments. The relevant part in the paper is Figure 6 (E-Then-Resolved rule) which differs from then (E-Then-Unresolved rule) by binding both the link and causal context. Thus, attaching a then to an already resolved context will give the causal context at the location of the then instead of where the promise originally resolved. We felt this was:
|
In async-listener we ended up monkey patching the callback given to |
@watson, note that the fix you pointed to doesn't solve the general case. It only solves the context loss for the case where the promise gets initialized in a no-context environment. The example I posted above does not work (correctly) with the current implementation of async-listener / continuation-local-storage. @mike-kaufman, @mrkmarron I'll go over the paper in more detail and respond back if I can or cannot reconcile my mental model. At the moment I am trying to reflect on the semantics that are actually offered by |
To provide a more concrete example for the no-context promise example case, consider: const app = express();
let authTokenPromise = fetch('some url');
app.get('/', (req, res) => {
authTokenPromise.then(() => {
// business logic.
// What is my context here?
});
});
|
should this remain open? [ I am trying to chase dormant issues to closure ] |
This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made. |
Forking discussion from: #141 (comment)
The text was updated successfully, but these errors were encountered: