diff options
Diffstat (limited to 'test/js/bun/net/keep-event-loop-alive.js')
-rw-r--r-- | test/js/bun/net/keep-event-loop-alive.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/js/bun/net/keep-event-loop-alive.js b/test/js/bun/net/keep-event-loop-alive.js new file mode 100644 index 000000000..28f8941fd --- /dev/null +++ b/test/js/bun/net/keep-event-loop-alive.js @@ -0,0 +1,47 @@ +(async () => { + const port = process.argv[2] ? parseInt(process.argv[2]) : null; + await Bun.sleep(10); + // failed connection + console.log("test 1: failed connection"); + try { + const socket = await Bun.connect({ + hostname: "localhost", + 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: "localhost", + 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: "localhost", + port, + socket: { data() {} }, + }); + socket.end(); + + // successful connection tls + console.log("test 4: successful connection [tls]"); + const socket2 = await Bun.connect({ + hostname: "localhost", + 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"); +})(); |