-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2778 from cloudflare/jsnell/handle-queuemicrotask…
…-reporterror-errors
- Loading branch information
Showing
5 changed files
with
89 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,31 @@ | ||
import { strictEqual } from 'assert'; | ||
|
||
export const test = { | ||
async test(_, env) { | ||
const resp = await env.subrequest.fetch('http://example.org'); | ||
strictEqual(await resp.text(), 'ok'); | ||
}, | ||
}; | ||
|
||
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', | ||
() => { | ||
// This error is not going to be catachable. The best we can do is to log it. | ||
// Unfortunately, workerd currently does not give us any mechanism to verify | ||
// that it was logged in the test. Let's make sure the response is handled | ||
// correctly at least. | ||
throw new Error('boom (real)'); | ||
}, | ||
{ once: true } | ||
); | ||
queueMicrotask(() => { | ||
throw new Error('boom (unused)'); | ||
}); | ||
await scheduler.wait(10); | ||
return new Response('ok'); | ||
}, | ||
}; |
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") | ||
], | ||
) | ||
), | ||
], | ||
); |
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