Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions test/js/bun/net/tcp-server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,28 @@ it("should not leak memory", async () => {
expect(stdout).toBe("");
expect(exitCode).toBe(0);
});

// stop(true) from alpnCallback or serverName closes the socket whose SSL call
// is on the stack, so that close waits until the callback returns. stop(true)
// once spun on that socket and never returned. The fixture runs in a child
// process, because such a spin also blocks the event loop that times a test
// out. The cases are not concurrent: the runner kills a child that a timed-out
// test leaves behind only when that test runs alone.
describe("TLS listener: stop(true) from inside a selection callback", () => {
it.each(["alpnCallback", "serverName"])("%s: stop(true) returns and the connection closes", async hook => {
await using proc = Bun.spawn({
cmd: [bunExe(), join(import.meta.dir, "tls-stop-from-selection-fixture.ts"), hook],
env: bunEnv,
stdout: "pipe",
stderr: "pipe",
});
const [stdout, stderr, exitCode] = await Promise.all([proc.stdout.text(), proc.stderr.text(), proc.exited]);
expect(stderr).toBe("");
expect(JSON.parse(stdout)).toEqual({
events: ["returned", "handshake:false", "close"],
clientConnected: false,
serverClosedFirst: true,
});
expect(exitCode).toBe(0);
});
});
63 changes: 63 additions & 0 deletions test/js/bun/net/tls-stop-from-selection-fixture.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading