-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle errors thrown by reportError in queueMicrotask
- Loading branch information
Showing
4 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { strictEqual } from 'assert'; | ||
|
||
export const test = { | ||
async test(_, env) { | ||
try { | ||
await env.subrequest.fetch('http://example.org'); | ||
} catch (e) { | ||
strictEqual(e.message, 'boom (real)'); | ||
} | ||
}, | ||
}; | ||
|
||
export default { | ||
async fetch() { | ||
// Throwing an error in the error event listener should not be catchable directly | ||
// but should cause the IoContext to be aborted with the error. | ||
addEventListener( | ||
'error', | ||
() => { | ||
throw new Error('boom (real)'); | ||
}, | ||
{ once: true } | ||
); | ||
queueMicrotask(() => { | ||
throw new Error('boom (unused)'); | ||
}); | ||
await scheduler.wait(1000); | ||
return new Response('should not see this'); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Workerd = import "/workerd/workerd.capnp"; | ||
|
||
const unitTests :Workerd.Config = ( | ||
services = [ | ||
( name = "error-in-error-event-test", | ||
worker = ( | ||
modules = [ | ||
(name = "worker", esModule = embed "error-in-error-event-test.js") | ||
], | ||
compatibilityDate = "2024-09-15", | ||
compatibilityFlags = ["nodejs_compat_v2"], | ||
bindings = [ | ||
(name = "subrequest", service = "error-in-error-event-test") | ||
], | ||
) | ||
), | ||
], | ||
); |