-
Notifications
You must be signed in to change notification settings - Fork 5k
usockets (Windows): one event-loop scope per uv_run; outermost tick frees #40021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -4433,3 +4433,25 @@ describe.concurrent("a socket closed by data() while its peer's reset is being d | |||||||
| expect(exitCode).toBe(0); | ||||||||
| }); | ||||||||
| }); | ||||||||
|
|
||||||||
| describe.concurrent("a socket closed by data() which then re-enters the event loop before returning", () => { | ||||||||
| // The fixture runs under `bun test` so that expect(promise).resolves can drive | ||||||||
| // nested event-loop ticks from inside the data callback. The closed socket must | ||||||||
| // stay allocated until the dispatch that invoked data() has returned; the loop | ||||||||
| // used to free it from a nested tick on Windows, and the outer dispatch then | ||||||||
| // read (and the allocator reused) freed memory. | ||||||||
| it("is not freed until the dispatch that called data() has returned", async () => { | ||||||||
| await using proc = Bun.spawn({ | ||||||||
| cmd: [bunExe(), "test", fileURLToPath(new URL("./close-inside-data-reentrant-fixture.ts", import.meta.url))], | ||||||||
| env: bunEnv, | ||||||||
| stdout: "pipe", | ||||||||
| stderr: "pipe", | ||||||||
| }); | ||||||||
| const [stdout, stderr, exitCode] = await Promise.all([proc.stdout.text(), proc.stderr.text(), proc.exited]); | ||||||||
| // stdout carries only the runner's version banner; results go to stderr. | ||||||||
| expect(stdout).toMatch(/^bun test v\S+ \(\S+\)\n$/); | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Relax the stdout banner assertion. The regex is fully anchored and requires a trailing
This PR targets Windows, so the test must be reliable there. Assert only that the banner is present. 🧪 Proposed fix for the stdout assertion- // stdout carries only the runner's version banner; results go to stderr.
- expect(stdout).toMatch(/^bun test v\S+ \(\S+\)\n$/);
+ // stdout carries only the runner's version banner; results go to stderr.
+ expect(stdout).toMatch(/^bun test v/);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||
| expect(stderr).toContain(" 1 pass"); | ||||||||
| expect(proc.signalCode).toBeNull(); | ||||||||
| expect(exitCode).toBe(0); | ||||||||
| }); | ||||||||
| }); | ||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: oven-sh/bun
Length of output: 2100
🏁 Script executed:
Repository: oven-sh/bun
Length of output: 50368
🏁 Script executed:
Repository: oven-sh/bun
Length of output: 38248
🏁 Script executed:
Repository: oven-sh/bun
Length of output: 50370
🏁 Script executed:
Repository: oven-sh/bun
Length of output: 50367
🏁 Script executed:
Repository: oven-sh/bun
Length of output: 45260
🏁 Script executed:
Repository: oven-sh/bun
Length of output: 393
Drain held endgames during loop teardown.
If
held_endgamesis non-empty,us_loop_freemust release it before its finaluv_run; otherwise, libuv never invokes those close callbacks and their owners remain allocated.🤖 Prompt for AI Agents