Skip to content

Commit fadf476

Browse files
committed
fixup test
1 parent 10fc527 commit fadf476

1 file changed

Lines changed: 17 additions & 16 deletions

File tree

test/tests/panic.spec.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,23 @@ describe("Panic Hook with WASM Reinitialization", () => {
9090
expect(responses[2].status).toBe(200);
9191
}
9292

93+
// Test 4: JS error recovery - counter should NOT reset after a JS error
94+
{
95+
const uniqueId = `JSERR_${Date.now()}_${Math.random()}`;
96+
97+
const resp1 = await mf.dispatchFetch(`${mfUrl}durable/${uniqueId}`);
98+
const match1 = (await resp1.text()).match(/unstored_count: (\d+)/);
99+
const count1 = match1 ? parseInt(match1[1]) : 0;
100+
101+
const jsErrorResp = await mf.dispatchFetch(`${mfUrl}test-js-error`);
102+
expect(jsErrorResp.status).toBe(500);
103+
104+
const resp2 = await mf.dispatchFetch(`${mfUrl}durable/${uniqueId}`);
105+
const match2 = (await resp2.text()).match(/unstored_count: (\d+)/);
106+
const count2 = match2 ? parseInt(match2[1]) : 0;
107+
expect(count2).toBe(count1 + 1);
108+
}
109+
93110
} else {
94111
// ===== PANIC=ABORT MODE TESTS (default) =====
95112
// In this mode, panics cause "Workers runtime canceled" and WASM reinitializes.
@@ -180,22 +197,6 @@ describe("Panic Hook with WASM Reinitialization", () => {
180197
expect(await normalResp.text()).toContain("unstored_count: 1");
181198
}
182199

183-
// JS error recovery test
184-
{
185-
await mf.dispatchFetch(`${mfUrl}durable/COUNTER`);
186-
const resp = await mf.dispatchFetch(`${mfUrl}durable/COUNTER`);
187-
expect(await resp.text()).toContain("unstored_count:");
188-
189-
const jsErrorResp = await mf.dispatchFetch(`${mfUrl}test-js-error`);
190-
expect(jsErrorResp.status).toBe(500);
191-
192-
const jsErrorText = await jsErrorResp.text();
193-
expect(jsErrorText).toContain("Workers runtime canceled");
194-
195-
const normalResp = await mf.dispatchFetch(`${mfUrl}durable/COUNTER`);
196-
expect(await normalResp.text()).toContain("unstored_count: 1");
197-
}
198-
199200
// out of memory recovery test
200201
{
201202
await mf.dispatchFetch(`${mfUrl}durable/COUNTER`);

0 commit comments

Comments
 (0)