Skip to content

Let await hang the isolate + observatory support. #23797

@lrhn

Description

@lrhn

Currently the VM stops an isolate when there are no queued events, scheduled timers or open receive ports. That means that code like:

main() async {
   await foo();
   print("DONE");
}

may terminate at the await if the foo code returns a future with nobody scheduled to complete it. That can happen through any number of bugs, but it is hard to debug when the VM just terminates. The code looks like direct-style code, and the user expects it to either stop at the await or continue after it - but not to exit in the middle.

Similarly it may fail to run finally blocks:

main() async {
  try {
     await foo();
  } finally {
     print("DONE");
  }
}

This can also terminate at the await, which is even less expected. It's not absolutely wrong because the code does't actually skip the finally, it just kills the isolate before it gets there.

In any case, it's unexpected behavior and hard to debug.

How about letting all pending await calls be registered by the isolate, and visible using the observatory, and not terminate the isolate while an await is waiting. That would change the behavior from early termination to look like a deadlock (which it most likely is). The user can then use the observatory to see in which places in async functions the isolate is currently waiting which will aid debugging - it's easy to see why "DONE" is not being printed if the await on the previous line is blocked.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.triagedIssue has been triaged by sub teamtype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions