mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 10:58:56 +00:00
Co-authored-by: 190n <7763597+190n@users.noreply.github.com> Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
23 lines
664 B
JavaScript
Generated
23 lines
664 B
JavaScript
Generated
import { Worker } from "node:worker_threads";
|
|
import assert from "node:assert";
|
|
|
|
const { promise, resolve, reject } = Promise.withResolvers();
|
|
|
|
process.on("worker", assert.fail);
|
|
process.once("uncaughtException", exception => {
|
|
try {
|
|
assert.strictEqual(exception.name, "TypeError");
|
|
assert(exception.message.includes("5 is not a function"), "message should include '5 is not a function'");
|
|
resolve();
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
});
|
|
|
|
// this will emit the "worker" event on the next tick
|
|
new Worker("", { eval: true });
|
|
// override it for when we try to emit the event and look up "emit"
|
|
process.emit = 5;
|
|
// wait for the error
|
|
await promise;
|