Skip to content

chore(node-integration-tests): Improve node test runner naming#21685

Open
mydea wants to merge 3 commits into
developfrom
fn/node-runner-changes
Open

chore(node-integration-tests): Improve node test runner naming#21685
mydea wants to merge 3 commits into
developfrom
fn/node-runner-changes

Conversation

@mydea

@mydea mydea commented Jun 22, 2026

Copy link
Copy Markdown
Member

Noticed that this is really verbose right now: When using createEsmAndCjsTests right now, it produes a rather deeply nested structure, which is technically correct but pretty verbose:

Screenshot 2026-06-22 at 12 53 20

This PR adjusts this to instead produce this:

Screenshot 2026-06-22 at 12 50 35

Note that it also suffixes "- failed" in cases where a given env (e.g. esm or cjs) fails, making this more apparent in the test results.

@mydea mydea self-assigned this Jun 22, 2026
@mydea mydea requested a review from a team as a code owner June 22, 2026 11:03
@mydea mydea requested review from JPeer264 and andreiborza and removed request for a team June 22, 2026 11:03

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0de77ce. Configure here.

Comment thread dev-packages/node-integration-tests/utils/runner.ts
Comment thread dev-packages/node-integration-tests/utils/runner.ts Outdated
Comment on lines +364 to +374
cleanupChildProcesses();

try {
await rm(tmpDirPath, { recursive: true, force: true });
} catch {
if (process.env.DEBUG) {
// eslint-disable-next-line no-console
console.error(`Failed to remove tmp dir: ${tmpDirPath}`);
}
}, 30_000);
});
}
}, 30_000);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Multiple afterAll hooks registered by createEsmAndCjsTests create a race condition, causing one hook to prematurely clear a global CLEANUP_STEPS set, leading to resource leaks.
Severity: MEDIUM

Suggested Fix

Refactor the cleanup mechanism to be robust against concurrent execution. Instead of a single global set that gets cleared, each afterAll hook should be responsible for cleaning up only the resources it created. This could be achieved by having the start() function return the specific cleanup functions required, which are then managed locally within the scope of createEsmAndCjsTests and its afterAll hook, avoiding the shared global state.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: dev-packages/node-integration-tests/utils/runner.ts#L362-L374

Potential issue: When `createEsmAndCjsTests` is invoked multiple times within the same
`describe` block, each call registers an `afterAll` hook. These hooks all reference a
single global `CLEANUP_STEPS` set. Because Vitest may run `afterAll` hooks in parallel,
a race condition is introduced. The first hook to complete will call
`cleanupChildProcesses`, which clears the entire global set. This can happen before
other tests' cleanup functions have been executed, or even added to the set, leading to
leaked child processes, docker containers, and mock servers during test runs.

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