fix(core): always register isolate to prevent silent foreground task drop#35408
Conversation
Make registration unconditional by making Handle optional. This prevents foreground tasks from being silently dropped when the isolate is not registered.
Deno Individual Contributor License AgreementAll contributors have signed the CLA. Thank you! This is an automated message from CLA Assistant |
|
A couple of non-blocking notes from reviewing this:
|
|
@haru0017 or anyone else here: is it possible that this change would have impacted I posted about this in Discord and a contributor there identified this PR as a potential root cause. There are a number of things here I do not understand, and I do not want to be creating more noise. Apologies in advance :) With that said, Mistral suggested for me a following patch, dropping two of the inner statements around let Some(handle) = entry.handle.as_ref() else { return };What do we think? |
|
Thanks for reporting this @rlaskey. I believe this change is causing the issue. Looking into it, I found that I've opened #35595 to fix the root cause by moving tokio runtime creation before For @bartlomieju I'd appreciate your thoughts on this. |
Fixes #35345
Registration in
ISOLATE_ENTRIESwas conditional onHandle::try_current(), so it could be skipped. When skipped,queue_taskandspawn_delayed_tasksilently dropped foreground tasks, causing the event loop to hang.This change makes registration unconditional by making
Handleoptional.queue_taskdoes not use the handle, so it works regardless.spawn_delayed_taskfalls back to immediate queuing when no handle is available, consistent with thePlatformImpldefaults.A missing entry now unambiguously means the isolate was already unregistered during shutdown, so dropping is safe.
This PR was prepared with assistance from Claude Code. All changes were directed and reviewed by the author.