Skip to content
Open
Changes from all commits
Commits
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
11 changes: 10 additions & 1 deletion test/cli/inspect/bun-inspector-protocol.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,19 @@ function checkObject(
const fixtureFiles = ["entry.mjs", "dep.cjs"];

test("the protocol snapshot in packages/bun-inspector-protocol matches what bun sends", async () => {
// reportError() counts as an unhandled error, so bun exits with code 1 as soon as the
// module body finishes, whatever else is scheduled. The second debugger statement keeps
// the inspectee parked after the session resumes it from the first one: the inspector's
// messages are written by the debugger thread, and a process that exits right after
// resuming can be gone before the Debugger.resume response and the Debugger.resumed
// event have been written to the socket.
using dir = tempDir("bun-inspector-protocol", {
"entry.mjs": `
import "./dep.cjs";
console.log("hello");
reportError(new Error("reported"));
debugger;
setInterval(() => {}, 60_000);
debugger;
`,
"dep.cjs": `module.exports = 1;`,
});
Expand Down Expand Up @@ -230,9 +236,12 @@ test("the protocol snapshot in packages/bun-inspector-protocol matches what bun
await send("LifecycleReporter.getModuleGraph");

const resumed = waitForEvent("Debugger.resumed");
const pausedAgain = waitForEvent("Debugger.paused");
await send("Debugger.resume");
await resumed;
await pausedAgain;
} finally {
// Closing the last connection resumes the parked inspectee, which then exits.
ws.close();
}

Expand Down
Loading