diff options
author | 2023-07-01 21:08:26 -0700 | |
---|---|---|
committer | 2023-07-01 21:08:26 -0700 | |
commit | c72c82b970eff579afedababad919b616acc51f7 (patch) | |
tree | c44bc7c5b45578075653ac611e7e3709e91cbe10 | |
parent | 6cae6ebafeac4ec2698dc746838b91b2f079f65f (diff) | |
download | bun-c72c82b970eff579afedababad919b616acc51f7.tar.gz bun-c72c82b970eff579afedababad919b616acc51f7.tar.zst bun-c72c82b970eff579afedababad919b616acc51f7.zip |
Make this test less flaky
-rw-r--r-- | test/js/bun/net/socket.test.ts | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/test/js/bun/net/socket.test.ts b/test/js/bun/net/socket.test.ts index 1da000834..5126067e6 100644 --- a/test/js/bun/net/socket.test.ts +++ b/test/js/bun/net/socket.test.ts @@ -105,7 +105,28 @@ it("should reject on connection error, calling both connectError() and rejecting }); it("should not leak memory when connect() fails", async () => { - await expectMaxObjectTypeCount(expect, "TCPSocket", 1, 100); + await (async () => { + var promises = new Array(100); + for (let i = 0; i < 100; i++) { + promises[i] = connect({ + hostname: "localhost", + port: 55555, + socket: { + connectError(socket, error) {}, + data() {}, + drain() {}, + close() {}, + end() {}, + error() {}, + open() {}, + }, + }); + } + await Promise.allSettled(promises); + promises.length = 0; + })(); + + await expectMaxObjectTypeCount(expect, "TCPSocket", 50, 100); }); // this also tests we mark the promise as handled if connectError() is called |