-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
CDP Runtime.evaluate does not drain async tasks #46966
Comments
hi @EmielM, The current Hermes CDP implementation is scoped to enable the set of features needed by the new RN debugger coming in 0.76. We specifically only meant for it to support the exact version of that RN DevTools. Unfortunately
In terms of the workarounds you talked about, could you please elaborate what that is?
What RN version are you using? The draining of microtask queue may be the responsibility of the code on the RN side and not something Hermes the engine controls. What are these promise tasks you're talking about? How are you creating them and what's the code you're using that's noticing them resolving after 5-10 seconds. Having code speaks most clearly. Thanks. |
@EmielM Right. That is only enabled with the New Architecture. But either way, Hermes doesn't control the event loop and the draining of the queue. I think we should transfer this issue to React Native. |
@EmielM please note that we also don't support just any Chrome DevTools, so if you're just opening up Chrome browser and using it then things are not 100% compatible. We only support the specific fork of DevTools we're calling React DevTools. The promise queue draining behavior looks to be RN related, so I'll transfer this issue over. |
|
|
@tmikov Alright (although that's a bit surprising to me as the CDPAgent implementation seems to live in the Hermes codebase) @dannysu Fair, but this doesn't work (as expected) in the RN inspector either: as I understand it's a pretty straight forward fork from the devtools project, and also sends @react-native-bot Yes! |
Thanks for reporting this!
We are aware of this issue and planning to fix this on React Native side. I will share more details once we confirm the timeline for it. |
…untimeScheduler Summary: # Changelog: [General] [Fixed] - Microtasks are now correctly executed after the code evaluation in Console panel of DevTools. Fixes facebook#46966. `runtimeExecutor` which is propagated here, is actually being used by Hermes: https://www.internalfb.com/code/fbsource/[cba75f2b515a]/xplat/js/react-native-github/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp?lines=112-113 The issue was that any expression that should be evaluated as part of `Runtime.evaluate` was not going through `RuntimeScheduler`, because specified `runtimeExecutor` was not going through it as well, and it was defined prior to `RuntimeScheduler`. Because of this, `RuntimeScheduler` was not draining out the microtasks queue and basically any scheduled Microtasks were not executed, see T200616136. With this fix, we create an executor that goes through `RuntimeScheduler`, which is using another executor that makes sure that all scheduled callbacks are only executed after `Inspector` was setup. It is extremely messy and in the future we should untangle these circular dependencies and try to simplify the approach. Differential Revision: D64552372
…untimeScheduler (facebook#47119) Summary: # Changelog: [General] [Fixed] - Microtasks are now correctly executed after the code evaluation in Console panel of DevTools. Fixes facebook#46966. `runtimeExecutor` which is propagated here, is actually being used by Hermes: https://www.internalfb.com/code/fbsource/[cba75f2b515a]/xplat/js/react-native-github/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp?lines=112-113 The issue was that any expression that should be evaluated as part of `Runtime.evaluate` was not going through `RuntimeScheduler`, because specified `runtimeExecutor` was not going through it as well, and it was defined prior to `RuntimeScheduler`. Because of this, `RuntimeScheduler` was not draining out the microtasks queue and basically any scheduled Microtasks were not executed, see T200616136. With this fix, we create an executor that goes through `RuntimeScheduler`, which is using another executor that makes sure that all scheduled callbacks are only executed after `Inspector` was setup. It is extremely messy and in the future we should untangle these circular dependencies and try to simplify the approach. Reviewed By: rubennorte Differential Revision: D64552372
Bug Description
I'm trying to run some automated testing scripts through the Hermes CDP interface using Runtime.evaluate.
First off, the
awaitPromises
flag does not seem to be supported at all. There are some work-arounds to this, so that's fine.A bigger issue seems to be that after
Runtime.evaluate
, planned Promise tasks are not executed. What I see is usually after a second or 5-10, the queue is triggered and drained again. (I also tried to workaround this by runningHermesInternal.drainJobs
after every command, but this is unexposed without hermes-internal-test-methods flag see; I didn't manage to enable that flag in an otherwise vanilla RN project either.)Tried to create a simple case to replicate, but the overall setup is pretty involving.
The text was updated successfully, but these errors were encountered: