Skip to content

chore: replace manual dispose and similar things with using - #42685

Open
Devin Rousso (dcrousso) wants to merge 15 commits into
microsoft:mainfrom
dcrousso:using-resource-cleanup
Open

Devin Rousso (dcrousso) wants to merge 15 commits into
microsoft:mainfrom
dcrousso:using-resource-cleanup

Conversation

@dcrousso

Copy link
Copy Markdown
Contributor

in many places this avoids having repeated foo?.dispose() in each early return branch and/or allows us to drop antry { ... } finally { ... } entirely

disposable registrations can own cleanup without being read

allow unused disposable declarations without dummy references
temporary handles can survive failed operations

use `using` and `await using` to dispose owned handles when their scope ends
archive cleanup is duplicated or skipped when extraction fails

add `Symbol.dispose` to `ZipFile` and tie owned archives to their scope
command helpers explicitly close their owned sockets in `finally`

add disposal methods to the wrappers and retain cleanup on success and failure
waiters already dispose themselves when operations fail

make disposal idempotent and tie owned waiters to their scope without duplicating completion events
conditional ownership currently requires manual handle cleanup

scope adopted and cross-world handles without disposing borrowed handles
report writers only close after successful serialization

close each writer at scope exit while awaiting pending output
database commands duplicate connection cleanup in `finally`

add `Symbol.dispose` to `TestResultsDb` and scope command-owned connections
unexpected task or shutdown errors can skip watcher cleanup

disarm scoped watchers while preserving their cleanup order and status reporting
test execution manually releases its abort registration in `finally`

add disposal support to `signalToPromise` and preserve listener cleanup before teardown
keypress registrations can clean up through both promise completion and their owner

make cleanup idempotent and end each registration before the next command or run
operation timeouts are manually cleared on each exit path

add a disposable timer adapter that preserves cancellation and works on older Node.js versions
temporary event subscriptions rely on manual cleanup

add synchronous disposal to registrations while preserving their asynchronous disposal API
installation lock cleanup is managed separately from acquisition

scope the release callback while retaining lock error diagnostics
stdio capture currently relies on paired claim and release calls

return an idempotent restoration token and retain the existing release API
@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

4 flaky ⚠️ [chromium-library] › library/browsercontext-page-event.spec.ts:160 › should work with Shift-clicking `@chromium-ubuntu-22.04-arm-node20`
⚠️ [firefox-library] › library/browsercontext-cookies-third-party.spec.ts:257 › third party 'Partitioned;' cookies `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/browsercontext-cookies-third-party.spec.ts:470 › top level 'Partitioned;' cookie and same origin iframe `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-page] › page/page-goto.spec.ts:90 › should work with Cross-Origin-Opener-Policy `@firefox-ubuntu-22.04-node20`

51692 passed, 1247 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

1 failed
❌ [firefox] › mcp/cli-core.spec.ts:131 › check @mcp-windows-latest-firefox

8508 passed, 1436 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

🟢 The one failure is a known pre-existing flake — this PR looks clear

Hi, I'm the Playwright bot and I triaged the red CI here.

[firefox] › mcp/cli-core.spec.ts:131 › check failed on mcp-windows-latest-firefox. The same test with the byte-identical error has failed on 7 other runs across unrelated PRs and main pushes, including a main push (sha d1ead3ec, run 34656353189) earlier the same evening. Nothing else in the report is a real failure.

Details

Overall: 51692 + 8508 passed, one failed test, four flaky. The failure reproduces on main without this PR, so I see no evidence of CI damage from this change.

Pre-existing flake / infra

Triaged by the Playwright bot - agent run

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