Skip to content

Browser: stop clearImmediate from retaining stale handles#782

Closed
brandonpayton wants to merge 1 commit into
mainfrom
gascity/kd-cfo/kd-c5i.9-fix-browser-clearimmediate-cancellation-leak-from-wave40
Closed

Browser: stop clearImmediate from retaining stale handles#782
brandonpayton wants to merge 1 commit into
mainfrom
gascity/kd-cfo/kd-c5i.9-fix-browser-clearimmediate-cancellation-leak-from-wave40

Conversation

@brandonpayton

@brandonpayton brandonpayton commented Jun 27, 2026

Copy link
Copy Markdown
Member

What this does

#907 already landed the broad PHP/platform batch, including its browser scheduling, worker coordination, and Vitest fixes, on ABI 39. This rewrite starts from current main and keeps that scheduling behavior.

The unique work here fixes the remaining browser clearImmediate leak:

  • keep cancellation state only while an immediate is pending;
  • use opaque immediate handles so a numeric browser setTimeout handle cannot cancel an unrelated immediate;
  • keep callbacks queued during a flush on the next MessageChannel macrotask;
  • use the same host-owned helper in the normal browser kernel worker and the network demo worker;
  • cover pending, unknown, and already-delivered handles with deterministic tests.

This extracts the useful part of #769 commit 43189956c73ee37cea6ce41d0447b775cbbf1eb8. It rebuilds the existing focused #782 instead of opening a duplicate PR.

What I removed

I did not replay #769's mmap, SQLite, VFS, package, or other composite changes. I also replaced #782's old numeric-handle implementation and stale pre-#907 ancestry instead of rebasing them mechanically.

ABI and packages

This does not change the kernel ABI, syscall marshalling, worker protocol, or generated ABI files. ABI stays at 39, and the ABI snapshot check passes.

No package manifest, package revision, VFS image source, or published package artifact changes. The browser images built for local validation were generated artifacts and are not part of this PR.

Validation

Run through scripts/dev-shell.sh on 3f133f92bd971cc83fecefcd64709ed7b9f13ade:

  • host declaration typecheck: passed;
  • focused polyfill Vitest: 4/4 passed;
  • full CI-shaped host Vitest: 1,270 passed, 2 expected failures, 130 skipped; Bun teardown rerun: 3/3 passed;
  • normal build.sh: passed;
  • browser production build: passed;
  • browser asset check: 92 imports resolved;
  • focused Chromium network-worker test: passed;
  • ./run.sh browser preparation and launch: passed;
  • non-slow Chromium suite against that server: 51 passed, 4 expected skips;
  • ABI snapshot/version check: passed;
  • git diff --check: passed.

Not run: Firefox, WebKit, slow browser tests, libc, POSIX, or Sortix suites. This change does not touch libc, syscalls, VFS semantics, or process state. GitHub CI is the remaining validation.

No performance claim is made, and performance was not measured.

@brandonpayton
brandonpayton force-pushed the gascity/kd-cfo/kd-c5i.9-fix-browser-clearimmediate-cancellation-leak-from-wave40 branch from 67aa067 to 3f133f9 Compare July 13, 2026 18:20
@brandonpayton brandonpayton changed the title browser: bound setImmediate cancellation state Browser: stop clearImmediate from retaining stale handles Jul 13, 2026
@brandonpayton

Copy link
Copy Markdown
Member Author

Closing this focused source PR because its unique stale clearImmediate handle cleanup is now carried by #934 at exact green head 260d75d5adc31b327f5591229dbfbb287d395fd6. #934 keeps it as a separate purpose commit and passed the full staging and browser gates. This is not a claim that this branch was merged verbatim.

@brandonpayton
brandonpayton deleted the gascity/kd-cfo/kd-c5i.9-fix-browser-clearimmediate-cancellation-leak-from-wave40 branch July 14, 2026 02:42
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