Skip to content

fix(dartpad-preview): cancel embedded workers during startup - #3985

Draft
LeonMollNetlight wants to merge 1 commit into
mainfrom
fix/dartpad-preview-worker-startup-cancellation
Draft

LeonMollNetlight wants to merge 1 commit into
mainfrom
fix/dartpad-preview-worker-startup-cancellation

Conversation

@LeonMollNetlight

@LeonMollNetlight LeonMollNetlight commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

When an embedded runtime is suspended during worker startup, its native worker currently keeps initializing until the session handshake returns a DartPad client. Rapid activation of several embeds can accumulate pending workers beyond the active runtime limit.

This change gives each startup attempt a Completer<void> and passes its future to DartPadSdk.dedicatedWorker(abortTrigger: ...). Suspension and close complete the trigger, allowing the SDK to terminate the pending worker before the handshake. Existing generation checks remain, and cleanup from a retired attempt cannot clear a resumed attempt’s trigger.

Draft dependency

This PR depends on the SDK client change on LeonMollNetlight/sdk:dartpad-cancel-worker-startup, which adds Future<void>? abortTrigger.

Create a separate abort trigger for each worker startup attempt and complete it when the runtime is suspended or closed. Preserve generation checks and protect resumed attempts from retired startup cleanup.

Add browser lifecycle regression coverage. Keep the published dartpad dependency unchanged; this draft requires a release exposing dedicatedWorker(abortTrigger:). No local override is included.
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

PR Health

Coverage ✔️
File Coverage

This check for test coverage is informational (issues shown here will not fail the PR).

This check can be disabled by tagging the PR with skip-coverage-check.

License Headers ✔️
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files
no missing headers

All source files should start with a license header.

Unrelated files missing license headers
Files
pkgs/dart_services/lib/src/context.dart
pkgs/dartpad_preview/examples/counter/lib/main.dart
pkgs/dartpad_preview/examples/fibonacci/bin/main.dart
pkgs/dartpad_preview/examples/snippet_dart/bin/main.dart
pkgs/dartpad_preview/examples/sunflower/lib/main.dart
pkgs/samples/lib/brick_breaker.dart
pkgs/samples/lib/fibonacci.dart
pkgs/samples/lib/hello_world.dart
pkgs/samples/lib/main.dart
pkgs/samples/lib/sunflower.dart

This check can be disabled by tagging the PR with skip-license-check.

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?

This check can be disabled by tagging the PR with skip-breaking-check.

Unused Dependencies ✔️
Package Status
None No packages found to check.

For details on how to fix these, see dependency_validator.

This check can be disabled by tagging the PR with skip-unused-dependencies-check.

API leaks ✔️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbol Leaking sources

This check can be disabled by tagging the PR with skip-leaking-check.

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant