Skip to content
Open
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5f6be28
bun:test: don't block on pending promises in expect().resolves/.rejects
robobun May 13, 2026
e205cc2
Add test.concurrent coverage for #25181
robobun May 13, 2026
c1d31cb
Address review: srcloc capture for inline snapshots, correct expect()…
robobun May 13, 2026
b927de1
Use in-flight counter instead of wall-clock for concurrent test
robobun May 13, 2026
7376ca8
Reject deferred promise on rerun setup failures; simplify MAX_INFLIGH…
robobun May 13, 2026
626583b
Reset counted_expect_call in postMatch; snapshot/restore across defer
robobun May 13, 2026
e3efc06
Fix CI: use bun.handleOom; await .resolves/.rejects in tests that rel…
robobun May 13, 2026
459a2ea
Fix wasm-streaming crash; address remaining review findings
robobun May 13, 2026
d57797e
Address remaining review: await fs.watch/worker_blob; snapshot flags;…
robobun May 13, 2026
ac962eb
Store deferred srcloc per PendingMatcher, not on shared Expect
robobun May 13, 2026
4ddd473
Await remaining .resolves/.rejects on pending promises in test suite
robobun May 13, 2026
04311d9
Await .rejects in deinitialization fixture
robobun May 13, 2026
3ea011e
Save/restore is_async_rerun in PendingMatcher.rerun
robobun May 13, 2026
ee14281
Port PendingMatcher to Rust after #30412 rewrite
robobun May 14, 2026
5a0f112
Address review: drop dead deferred_result; fix double-GC in apply_cus…
robobun May 14, 2026
905160e
Drop dead result_value_set_cached write in maybe_defer_matcher
robobun May 14, 2026
03f38b7
Use bun_core::heap::{into_raw, take} per repo convention
robobun May 14, 2026
e090e75
Fix stale doc comment; await .resolves in inspector-protocol websocke…
robobun May 15, 2026
a7193a1
ci: retrigger (alpine mysql_native_password Docker health-check flake)
robobun May 15, 2026
bce8920
Revert bake-codegen.ts JSON.stringify workaround (obsoleted by #30679)
robobun May 16, 2026
614a0f6
Update matcher_prelude/mock_prologue doc comments for MatcherStart/Mo…
robobun May 16, 2026
43128b5
Await deferred .resolves in pidfd-exit-nested-tick test to avoid LSan…
robobun May 21, 2026
c6ed4f1
Fix SAFETY comment in RerunGuard::drop to reference the correct owner
robobun May 21, 2026
28a04ee
Store deferred-matcher state in a GC-managed context instead of a Box
robobun May 24, 2026
9959864
Await maxRedirects rejects assertion; fix two stale deferred-matcher …
robobun Jun 5, 2026
5c06bfd
Settle the deferred even when a context slot read fails in on_settle
robobun Jun 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions packages/bun-inspector-protocol/test/inspector/websocket.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,69 +7,69 @@ let server: Server;
let url: URL;

describe("WebSocketInspector", () => {
test("fails without a URL", () => {
test("fails without a URL", async () => {
const ws = new WebSocketInspector();
const fn = mock(error => {
expect(error).toBeInstanceOf(Error);
});
ws.on("Inspector.error", fn);
expect(ws.start()).resolves.toBeFalse();
await expect(ws.start()).resolves.toBeFalse();
expect(fn).toHaveBeenCalled();
});

test("fails with invalid URL", () => {
test("fails with invalid URL", async () => {
const ws = new WebSocketInspector("notaurl");
const fn = mock(error => {
expect(error).toBeInstanceOf(Error);
});
ws.on("Inspector.error", fn);
expect(ws.start()).resolves.toBeFalse();
await expect(ws.start()).resolves.toBeFalse();
expect(fn).toHaveBeenCalled();
});

test("fails with valid URL but no server", () => {
test("fails with valid URL but no server", async () => {
const ws = new WebSocketInspector("ws://localhost:0/doesnotexist/");
const fn = mock(error => {
expect(error).toBeInstanceOf(Error);
});
ws.on("Inspector.error", fn);
expect(ws.start()).resolves.toBeFalse();
await expect(ws.start()).resolves.toBeFalse();
expect(fn).toHaveBeenCalled();
});

test("fails with invalid upgrade response", () => {
test("fails with invalid upgrade response", async () => {
const ws = new WebSocketInspector(new URL("/", url));
const fn = mock(error => {
expect(error).toBeInstanceOf(Error);
});
ws.on("Inspector.error", fn);
expect(ws.start()).resolves.toBeFalse();
await expect(ws.start()).resolves.toBeFalse();
expect(fn).toHaveBeenCalled();
});

test("can connect to a server", () => {
test("can connect to a server", async () => {
const ws = new WebSocketInspector(url);
const fn = mock(() => {
expect(ws.closed).toBe(false);
});
ws.on("Inspector.connected", fn);
expect(ws.start()).resolves.toBeTrue();
await expect(ws.start()).resolves.toBeTrue();
expect(fn).toHaveBeenCalled();
ws.close();
});

test("can disconnect from a server", () => {
test("can disconnect from a server", async () => {
const ws = new WebSocketInspector(url);
const fn = mock(() => {
expect(ws.closed).toBeTrue();
});
ws.on("Inspector.disconnected", fn);
expect(ws.start()).resolves.toBeTrue();
await expect(ws.start()).resolves.toBeTrue();
ws.close();
expect(fn).toHaveBeenCalled();
});

test("can connect to a server multiple times", () => {
test("can connect to a server multiple times", async () => {
const ws = new WebSocketInspector(url);
const fn0 = mock(() => {
expect(ws.closed).toBeFalse();
Expand All @@ -80,14 +80,14 @@ describe("WebSocketInspector", () => {
});
ws.on("Inspector.disconnected", fn1);
for (let i = 0; i < 3; i++) {
expect(ws.start()).resolves.toBeTrue();
await expect(ws.start()).resolves.toBeTrue();
ws.close();
}
expect(fn0).toHaveBeenCalledTimes(3);
expect(fn1).toHaveBeenCalledTimes(3);
});

test("can send a request", () => {
test("can send a request", async () => {
const ws = new WebSocketInspector(url);
const fn0 = mock(request => {
expect(request).toStrictEqual({
Expand All @@ -108,14 +108,14 @@ describe("WebSocketInspector", () => {
});
});
ws.on("Inspector.response", fn1);
expect(ws.start()).resolves.toBeTrue();
expect(ws.send("Debugger.setPauseOnAssertions", { enabled: true })).resolves.toMatchObject({ ok: true });
await expect(ws.start()).resolves.toBeTrue();
await expect(ws.send("Debugger.setPauseOnAssertions", { enabled: true })).resolves.toMatchObject({ ok: true });
expect(fn0).toHaveBeenCalled();
expect(fn1).toHaveBeenCalled();
ws.close();
});

test("can send a request before connecting", () => {
test("can send a request before connecting", async () => {
const ws = new WebSocketInspector(url);
const fn0 = mock(request => {
expect(request).toStrictEqual({
Expand All @@ -136,14 +136,14 @@ describe("WebSocketInspector", () => {
});
ws.on("Inspector.response", fn1);
const request = ws.send("Runtime.enable");
expect(ws.start()).resolves.toBe(true);
expect(request).resolves.toMatchObject({ ok: true });
await expect(ws.start()).resolves.toBe(true);
await expect(request).resolves.toMatchObject({ ok: true });
expect(fn0).toHaveBeenCalledTimes(2);
expect(fn1).toHaveBeenCalled();
ws.close();
});

test("can receive an event", () => {
test("can receive an event", async () => {
const ws = new WebSocketInspector(url);
const fn = mock(event => {
expect(event).toStrictEqual({
Expand All @@ -154,8 +154,8 @@ describe("WebSocketInspector", () => {
});
});
ws.on("Inspector.event", fn);
expect(ws.start()).resolves.toBeTrue();
expect(ws.send("Debugger.enable")).resolves.toMatchObject({ ok: true });
await expect(ws.start()).resolves.toBeTrue();
await expect(ws.send("Debugger.enable")).resolves.toMatchObject({ ok: true });
expect(fn).toHaveBeenCalled();
ws.close();
});
Expand Down
1 change: 1 addition & 0 deletions src/jsc/CallFrame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ impl<const MAX: usize> Arguments<MAX> {
}
}

#[derive(Clone, Copy)]
pub struct CallerSrcLoc {
pub str: bun_core::String,
pub line: c_uint,
Expand Down
4 changes: 4 additions & 0 deletions src/jsc/bindings/ZigGlobalObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3872,6 +3872,10 @@ GlobalObject::PromiseFunctions GlobalObject::promiseHandlerID(Zig::FFIFunction h
return GlobalObject::PromiseFunctions::Bun__HTTPRequestContextDebugH3__onResolve;
} else if (handler == Bun__HTTPRequestContextDebugH3__onResolveStream) {
return GlobalObject::PromiseFunctions::Bun__HTTPRequestContextDebugH3__onResolveStream;
} else if (handler == Bun__Expect__PendingMatcher__onResolve) {
return GlobalObject::PromiseFunctions::Bun__Expect__PendingMatcher__onResolve;
} else if (handler == Bun__Expect__PendingMatcher__onReject) {
return GlobalObject::PromiseFunctions::Bun__Expect__PendingMatcher__onReject;
} else {
RELEASE_ASSERT_NOT_REACHED();
}
Expand Down
4 changes: 3 additions & 1 deletion src/jsc/bindings/ZigGlobalObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,10 @@ class GlobalObject : public Bun::GlobalScope {
Bun__HTTPRequestContextDebugH3__onRejectStream,
Bun__HTTPRequestContextDebugH3__onResolve,
Bun__HTTPRequestContextDebugH3__onResolveStream,
Bun__Expect__PendingMatcher__onResolve,
Bun__Expect__PendingMatcher__onReject,
};
static constexpr size_t promiseFunctionsSize = 42;
static constexpr size_t promiseFunctionsSize = 44;

static PromiseFunctions promiseHandlerID(SYSV_ABI EncodedJSValue (*handler)(JSC::JSGlobalObject* arg0, JSC::CallFrame* arg1));

Expand Down
2 changes: 2 additions & 0 deletions src/jsc/bindings/headers.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/jsc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,7 @@ pub use self::js_object::{ExternColumnIdentifier, ExternColumnIdentifierValue, J
// ──────────────────────────────────────────────────────────────────────────
#[path = "CallFrame.rs"]
pub mod call_frame;
pub use self::call_frame::{ArgumentsSlice, CallFrame};
pub use self::call_frame::{ArgumentsSlice, CallFrame, CallerSrcLoc};

/// Lives here (not in `bun_sys_jsc`) because the orphan
/// rule requires either the trait or the type to be local; `FromJsEnum` is.
Expand Down
Loading
Loading