mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
chore: fix flaky rejection_handled_web_process (#23817)
Closes https://github.com/denoland/deno/issues/23712
This commit is contained in:
parent
e389917535
commit
1a788b58a0
5 changed files with 18 additions and 12 deletions
|
@ -202,12 +202,3 @@ itest!(unhandled_rejection_web_process {
|
|||
envs: env_vars_for_npm_tests(),
|
||||
http_server: true,
|
||||
});
|
||||
|
||||
// Ensure that Web `onrejectionhandled` is fired before
|
||||
// Node's `process.on('rejectionHandled')`.
|
||||
itest!(rejection_handled_web_process {
|
||||
args: "run -A --quiet node/rejection_handled_web_process.ts",
|
||||
output: "node/rejection_handled_web_process.ts.out",
|
||||
envs: env_vars_for_npm_tests(),
|
||||
http_server: true,
|
||||
});
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
// Ensure that Web `onrejectionhandled` is fired before
|
||||
// Node's `process.on('rejectionHandled')`.
|
||||
{
|
||||
"args": "run -A --quiet rejection_handled_web_process.ts",
|
||||
"output": "rejection_handled_web_process.ts.out"
|
||||
}
|
|
@ -3,6 +3,8 @@ import process from "node:process";
|
|||
|
||||
console.log(chalk.red("Hello world!"));
|
||||
|
||||
const { promise, resolve } = Promise.withResolvers();
|
||||
|
||||
globalThis.addEventListener("unhandledrejection", (e) => {
|
||||
console.log('globalThis.addEventListener("unhandledrejection");');
|
||||
e.preventDefault();
|
||||
|
@ -14,6 +16,7 @@ globalThis.addEventListener("rejectionhandled", (_) => {
|
|||
|
||||
process.on("rejectionHandled", (_) => {
|
||||
console.log("Node rejectionHandled");
|
||||
resolve();
|
||||
});
|
||||
|
||||
const a = Promise.reject(1);
|
||||
|
@ -21,6 +24,12 @@ setTimeout(() => {
|
|||
a.catch(() => console.log("Added catch handler to the promise"));
|
||||
}, 100);
|
||||
|
||||
setTimeout(() => {
|
||||
const exitTimeout = setTimeout(() => {
|
||||
console.error("timeout expired");
|
||||
Deno.exit(1);
|
||||
}, 30_000);
|
||||
|
||||
promise.then(() => {
|
||||
console.log("Success");
|
||||
}, 1000);
|
||||
clearTimeout(exitTimeout);
|
||||
});
|
|
@ -216,7 +216,7 @@ async function ensureNoNewITests() {
|
|||
// Read the comment above. Please don't increase these numbers!
|
||||
"lsp_tests.rs": 0,
|
||||
"node_compat_tests.rs": 4,
|
||||
"node_unit_tests.rs": 3,
|
||||
"node_unit_tests.rs": 2,
|
||||
"npm_tests.rs": 98,
|
||||
"pm_tests.rs": 0,
|
||||
"publish_tests.rs": 0,
|
||||
|
|
Loading…
Reference in a new issue