When V8 is about to call a Promise handler, is there any way to determine 
what Context that handler function lives in?  I can use 
PromiseHookType::kBefore learn when the microtask queue is about to call a 
Promise handler, but in the hook if I 
call promise->GetIsolate()->GetCurrentContext() I don't get the context of 
the handler function that is about to be executed.  Is there any way to 
determine the Context of the function that the PromiseReactionJob is about 
to run?  If there was a way to access the PromiseReaction record itself, I 
assume I could just look at the handler function's CreationContext, but the 
PromiseReaction record doesn't seem to be exposed to the V8 public API.

In case it's helpful, here's the larger use case: I have some APIs that can 
be called by different clients, and each client's code is in a different 
Context.  I'd like the API to be able to identify which client is currently 
executing when the API is called.  For APIs implemented as native code, 
it's easy to check GetCallingContext().  But if any APIs are implemented in 
JS, then the current Context switches to the Context the API's own JS code 
lives in, and it's no longer possible (as far as I can tell) to look up the 
stack to see what Context the caller was in.

So I am wondering if I can just keep track of each time I'm about to enter 
the client code.  This is easy enough to do when my own code is about to 
invoke a piece of client code explicitly, but when the client code creates 
a Promise or attaches a Promise handler, I'm not in control of the moment 
that handler runs -- it happens down inside RunMicrotasks(), opaque to my 
embedder code.  Is there any way to introspect what JS code is going to be 
entered when I call RunMicrotasks()?

Thanks for the advice!

- Peter

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to