fix(test): run cleanup when a teardown hook fails (runner + Bun adapter) - #1346
Closed
sam-goodwin wants to merge 1 commit into
Closed
fix(test): run cleanup when a teardown hook fails (runner + Bun adapter)#1346sam-goodwin wants to merge 1 commit into
sam-goodwin wants to merge 1 commit into
Conversation
…r + Bun adapter) Companion to #1341's Vitest aroundAll fix — the other two adapters had the same class of leak, each with a different trigger: - alchemy-test runner: runAfterAll short-circuited on the first failing hook, so a failing teardown assertion dropped every later afterAll — including Test.make's fallback that closes the shared scope and local provider sidecar. afterAll hooks now all run; failures aggregate. - Test/Bun: bun:test stops the afterAll chain once a hook throws (verified empirically; registration order and afterAll-after-failed- beforeAll are fine), skipping the microtask-registered fallback. The adapter now guards user teardowns: on failure it runs the idempotent cleanup before rethrowing. Both regression tests are red against the previous code. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
|
Install the packages built from this commit: Alchemyalchemy bun add https://pkg.ing/alchemy/e4d10d1@alchemy.run/better-auth bun add https://pkg.ing/@alchemy.run/better-auth/e4d10d1@alchemy.run/cloudflare-runtime bun add https://pkg.ing/@alchemy.run/cloudflare-runtime/e4d10d1@alchemy.run/frontend-frameworks bun add https://pkg.ing/@alchemy.run/frontend-frameworks/e4d10d1@alchemy.run/node-utils bun add https://pkg.ing/@alchemy.run/node-utils/e4d10d1@alchemy.run/pr-package bun add https://pkg.ing/@alchemy.run/pr-package/e4d10d1@alchemy.run/floci bun add https://pkg.ing/@alchemy.run/floci/e4d10d1Distilled@distilled.cloud/core bun add https://pkg.ing/@distilled.cloud/core/dd2a322@distilled.cloud/aws bun add https://pkg.ing/@distilled.cloud/aws/dd2a322@distilled.cloud/axiom bun add https://pkg.ing/@distilled.cloud/axiom/dd2a322@distilled.cloud/cloudflare bun add https://pkg.ing/@distilled.cloud/cloudflare/dd2a322@distilled.cloud/hetzner bun add https://pkg.ing/@distilled.cloud/hetzner/dd2a322@distilled.cloud/neon bun add https://pkg.ing/@distilled.cloud/neon/dd2a322@distilled.cloud/planetscale bun add https://pkg.ing/@distilled.cloud/planetscale/dd2a322 |
Contributor
Author
|
Folded into #1339. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Companion to #1341: the Vitest adapter's teardown-ordering fix revealed a broader class — a failing teardown hook silently drops later cleanup, leaking the shared scope and local provider sidecar for the rest of the test process. The other two adapters each had it with a different trigger.
alchemy-test runner —
runAfterAllshort-circuited on the first failing hook:beforeAllkeeps short-circuit semantics (a failed setup invalidates what follows); teardowns all run, matching every mainstream runner's contract.Test/Bun — probed bun:test empirically:
afterAllruns in registration order ✓, and still runs after a failedbeforeAll✓, but the chain stops once a hook throws — skipping the microtask-registered fallback. The adapter now guards user teardowns:Both regression tests are two-sided and red against the previous code:
alchemy-test/test/Runner.test.ts— a file with a failing firstafterAllmust still run the second (sentinel asserted from the spawned runner's output) and exit non-zero.test/Test/Bun.test.ts— spawns realbun teston a fixture using the public adapter; a shared-scope finalizer sentinel proves the cleanup ran after the throwing user teardown.