Feature Request: v8::Isolate::setPromiseHook to accept multiple hooks

78 views
Skip to first unread message

Sajal Khandelwal

unread,
Feb 6, 2021, 12:50:00 AM2/6/21
to v8-dev
Hello,

v8::Isolate::setPromiseHook seems to override the last set hook. This becomes inconvenient when some other piece of code in a large codebase (of which you may have no control, for example async_hooks in node js) overrides the hook. Would it make sense to add another method, perhaps addPromiseHook that would invoke more than one hook? Similar reasoning stands for v8::Isolate::SetPromiseRejectCallback.


Yang Guo

unread,
Feb 6, 2021, 12:54:14 AM2/6/21
to v8-...@googlegroups.com
Is there a problem implementing this in the embedder? I think that would be the preferred solution. To add complexity where it is necessary.

Cheers,

Yang

On Sat, 6 Feb 2021, 06:50 Sajal Khandelwal, <saj...@gmail.com> wrote:
Hello,

v8::Isolate::setPromiseHook seems to override the last set hook. This becomes inconvenient when some other piece of code in a large codebase (of which you may have no control, for example async_hooks in node js) overrides the hook. Would it make sense to add another method, perhaps addPromiseHook that would invoke more than one hook? Similar reasoning stands for v8::Isolate::SetPromiseRejectCallback.


--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/6eb42f45-d9a0-47d1-bbf7-e4125459b1b4n%40googlegroups.com.

Sajal Khandelwal

unread,
Feb 6, 2021, 7:37:16 AM2/6/21
to v8-dev
Thank you, Yang.
I'd imagine that'd be the easiest.

But off the top of my head, I am imagining a scenario of what if some random C++ native add on, chose to replace that hook for its own use. Basically, the concern being even as an embedder, you might not have total control of what some random library might choose to replace that hook.

Sajal Khandelwal

unread,
Feb 9, 2021, 9:01:32 PM2/9/21
to v8-dev
Hello, Yang. I was wondering if you could me with my previous comment. Thank you.

Yang Guo

unread,
Feb 10, 2021, 3:36:14 AM2/10/21
to v8-...@googlegroups.com
I personally think that it's a bad idea to expose V8 to several different embedders in the same process. The V8 API is not designed for that and it will cause issues, not only the one you are pointing out here.

Reply all
Reply to author
Forward
0 new messages