Skip to content

Commit

Permalink
Start testing for oven-sh#2489
Browse files Browse the repository at this point in the history
This appears to be a bug within the HTTPS (TLS?) connection code,
where it waits for some initial handshake before allowing timeouts
to interrupt the connection. I seen one of these fetches give up, even
from a native timeout.
  • Loading branch information
Plecra committed Apr 24, 2023
1 parent 98209b8 commit e776407
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/regression/issue/02489.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { sleep, listen } from "bun";
import { describe, expect, it } from "bun:test";

describe("an https fetch to a silent TCP socket", () => {
const listener = listen({
port: 0,
hostname: "localhost",
socket: {
data() {},
},
});
it("should respond to abort signals", async () => {
const signal = AbortSignal.timeout(1);

// After 1ms, the signal should abort the fetch and reject its promise. (with an http URL, this behaviour is seen)
// As of this commit, however, the fetch will hang indefinitely.
// We detect this by requiring the rejection after waiting 250ms.
expect(() =>
Promise.race([
sleep(250),
fetch(`https://127.0.0.1:${listener.port}`, { signal: signal }).then(res => res.text()),
]),
).toThrow(new DOMException("The operation timed out."));
});
});

0 comments on commit e776407

Please sign in to comment.