mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
* WIP missing keepalive * cleanup * is a Bun.sleep bug? * no bun sleep * fix exception * revert * fix setTimeout/Bun.sleep * add Bun.sleep keepalive test * fixes * one more bonus fix * fix early firing of timers * use localhost and pass the server.hostname * opsie
49 lines
1.2 KiB
JavaScript
49 lines
1.2 KiB
JavaScript
(async () => {
|
|
const port = process.argv[2] ? parseInt(process.argv[2]) : null;
|
|
const hostname = process.argv[3] ? process.argv[3] : "localhost";
|
|
await Bun.sleep(10);
|
|
// failed connection
|
|
console.log("test 1: failed connection");
|
|
try {
|
|
const socket = await Bun.connect({
|
|
hostname: hostname,
|
|
port: 9999,
|
|
socket: { data() {} },
|
|
});
|
|
socket.end();
|
|
} catch (error) {}
|
|
// failed connection tls
|
|
console.log("test 2: failed connection [tls]");
|
|
try {
|
|
const socket = await Bun.connect({
|
|
hostname: hostname,
|
|
port: 9999,
|
|
socket: { data() {} },
|
|
tls: true,
|
|
});
|
|
socket.end();
|
|
} catch (error) {}
|
|
if (port) {
|
|
// successful connection
|
|
console.log("test 3: successful connection");
|
|
const socket = await Bun.connect({
|
|
hostname: hostname,
|
|
port,
|
|
socket: { data() {} },
|
|
});
|
|
socket.end();
|
|
|
|
// successful connection tls
|
|
console.log("test 4: successful connection [tls]");
|
|
const socket2 = await Bun.connect({
|
|
hostname: hostname,
|
|
port,
|
|
socket: { data() {} },
|
|
});
|
|
socket2.end();
|
|
} else {
|
|
console.log("run with a port as an argument to try the success situation");
|
|
}
|
|
console.log("success: event loop was not killed");
|
|
})();
|