Skip to content

fix(core): drain worker IPC writes before async leak checks - #1863

Merged
9aoy merged 4 commits into
mainfrom
9aoy/fix-async-leak-writewrap
Sep 18, 2026
Merged

9aoy merged 4 commits into
mainfrom
9aoy/fix-async-leak-writewrap

Conversation

@9aoy

@9aoy 9aoy commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

Motivation

Async leak detection can sample Rstest's own fork-worker process.send() WRITEWRAP before the IPC write has completed, causing a false positive in otherwise clean tests. The reported zlib failure was this worker IPC race; the zlib stream itself is already covered by the existing ZLIB handling.

Changes

  • track outstanding local process.send() callbacks inside ForksChannel
  • drain pending RPC writes after the file run and before async leak sampling
  • keep runner hooks and RPC responses asynchronous; only the local IPC write completion is awaited
  • settle pending writes when the IPC channel disconnects, while thread workers remain a no-op
  • keep WRITEWRAP detectable so user-created IPC leaks are not globally hidden
  • add unit coverage for write draining and disconnect behavior

Validation

  • core lint and build
  • root typecheck
  • fork channel and RPC unit tests
  • async leak e2e in ESM and CommonJS output modes
  • targeted zlib async leak e2e passed 30 consecutive runs
  • pnpm check-unused

@github-actions

github-actions Bot commented Sep 18, 2026

Copy link
Copy Markdown

Rsdoctor Bundle Diff Analysis

⚠️ Note: The latest commit (a2ee78bb13) does not have baseline artifacts. Using commit bbefea9a38 for baseline comparison instead. If this seems incorrect, please wait a few minutes and try rerunning the workflow.

Found 13 projects in monorepo, 1 project with changes.

📊 Quick Summary
Project Total Size Change
adapter-rsbuild 6.1 KB 0
adapter-rslib 51.1 KB 0
adapter-rspack 12.4 KB 0
browser 1.1 MB 0
browser-react 6.4 KB 0
coverage-istanbul 20.1 KB 0
coverage-v8 82.2 KB 0
playwright 53.8 KB 0
browser/client 79.6 KB 0
core/browser 645.2 KB 0
core/main 2.0 MB +1.8 KB (0.1%)
vscode/extension 1.3 MB 0
vscode/worker 18.4 KB 0
📋 Detailed Reports (Click to expand)

📁 core/main

Path: packages/core/.rsdoctor/main/rsdoctor-data.json

📌 Baseline Commit: bbefea9a38 | PR: #1861

Metric Current Baseline Change
📊 Total Size 2.0 MB 2.0 MB +1.8 KB (0.1%)
📄 JavaScript 1.6 MB 1.6 MB +1.4 KB (0.1%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 440.7 KB 440.3 KB +402.0 B (0.1%)

📦 Download Diff Report: core/main Bundle Diff

Generated by Rsdoctor GitHub Action

@9aoy 9aoy changed the title fix(core): ignore worker IPC write resources in async leak detection fix(core): await worker IPC writes before async leak detection Sep 18, 2026
@9aoy 9aoy changed the title fix(core): await worker IPC writes before async leak detection fix(core): drain worker IPC writes before async leak checks Sep 18, 2026
@9aoy

9aoy commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: b72ff71ce8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@9aoy
9aoy merged commit 5b77918 into main Sep 18, 2026
17 of 19 checks passed
@9aoy
9aoy deleted the 9aoy/fix-async-leak-writewrap branch September 18, 2026 09:09
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