mirror of
https://github.com/oven-sh/bun
synced 2026-02-18 23:01:58 +00:00
test for abort signal reason gc problem
This commit is contained in:
21
test/js/web/abort/abort-signal-reason.test.js
Normal file
21
test/js/web/abort/abort-signal-reason.test.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import { expect, test, describe } from "bun:test";
|
||||
|
||||
describe("AbortSignal reason", () => {
|
||||
// https://bugs.webkit.org/show_bug.cgi?id=293319
|
||||
test("reason is preserved after GC", () => {
|
||||
const controller = new AbortController();
|
||||
controller.signal;
|
||||
controller.abort(new Error("one two three")); // error must be defined inline so it doesn't get kept alive
|
||||
Bun.gc(true);
|
||||
|
||||
let error;
|
||||
try {
|
||||
controller.signal.throwIfAborted();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error).toBe(controller.signal.reason);
|
||||
expect(error.message).toBe("one two three");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user