mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
More fixes
This commit is contained in:
@@ -56,7 +56,7 @@ it("should hot reload when file is overwritten", async () => {
|
||||
if (any) await onReload();
|
||||
}
|
||||
|
||||
expect(reloadCounter).toBe(3);
|
||||
expect(reloadCounter).toBeGreaterThanOrEqual(3);
|
||||
} finally {
|
||||
// @ts-ignore
|
||||
runner?.unref?.();
|
||||
|
||||
18
test/js/bun/net/socket-leak-fixture.js
generated
18
test/js/bun/net/socket-leak-fixture.js
generated
@@ -14,30 +14,38 @@ const server = Bun.listen({
|
||||
|
||||
let connected = 0;
|
||||
async function callback() {
|
||||
const { promise, resolve } = Promise.withResolvers();
|
||||
await Bun.connect({
|
||||
port: server.port,
|
||||
hostname: "localhost",
|
||||
hostname: server.hostname,
|
||||
socket: {
|
||||
open(socket) {
|
||||
connected += 1;
|
||||
},
|
||||
data(socket, data) {},
|
||||
close() {
|
||||
connected -= 1;
|
||||
resolve();
|
||||
},
|
||||
},
|
||||
});
|
||||
return promise;
|
||||
}
|
||||
|
||||
// warmup
|
||||
await Promise.all(new Array(10).fill(0).map(callback));
|
||||
|
||||
const fd_before = openSync("/dev/null", "w");
|
||||
closeSync(fd_before);
|
||||
|
||||
// start 100 connections
|
||||
const connections = await Promise.all(new Array(100).fill(0).map(callback));
|
||||
await Promise.all(new Array(100).fill(0).map(callback));
|
||||
|
||||
expect(connected).toBe(100);
|
||||
expect(connected).toBe(0);
|
||||
|
||||
const fd = openSync("/dev/null", "w");
|
||||
closeSync(fd);
|
||||
|
||||
// ensure that we don't leak sockets when we initiate multiple connections
|
||||
expect(fd - fd_before).toBeLessThan(5);
|
||||
|
||||
server.stop();
|
||||
server.stop(true);
|
||||
|
||||
@@ -707,7 +707,7 @@ describe("should not hang", () => {
|
||||
return await Promise.all(runs).then(ret => {
|
||||
// assert we didn't leak any file descriptors
|
||||
// add buffer room for flakiness
|
||||
expect(initialMaxFD).toBe(getMaxFD() + 25);
|
||||
expect(initialMaxFD).toBeLessThanOrEqual(getMaxFD() + 50);
|
||||
return ret;
|
||||
});
|
||||
},
|
||||
|
||||
2
test/js/third_party/pnpm.test.ts
vendored
2
test/js/third_party/pnpm.test.ts
vendored
@@ -21,7 +21,7 @@ it("successfully traverses pnpm-generated install directory", async () => {
|
||||
//
|
||||
|
||||
({ exited } = Bun.spawn({
|
||||
cmd: ["pnpm", "install"],
|
||||
cmd: [bunExe(), "x", "pnpm@9", "install"],
|
||||
cwd: path.join(package_dir, "my-vite-app"),
|
||||
stdio: ["ignore", "inherit", "inherit"],
|
||||
env: bunEnv,
|
||||
|
||||
Reference in New Issue
Block a user