summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-05-14 19:51:51 -0400
committerGitHub <noreply@github.com>2024-05-14 23:51:51 +0000
commit1a788b58a0e80c4504a0fdf5d47db41c46dc8d37 (patch)
tree4b780c3a09d92c18a381a25d7213828721c05b1f
parente389917535e8e7ef13920a96f9c9c1e1ec2b2c55 (diff)
chore: fix flaky rejection_handled_web_process (#23817)
Closes https://github.com/denoland/deno/issues/23712
-rw-r--r--tests/integration/node_unit_tests.rs9
-rw-r--r--tests/specs/node/rejection_handled_web_process/__test__.jsonc6
-rw-r--r--tests/specs/node/rejection_handled_web_process/rejection_handled_web_process.ts (renamed from tests/testdata/node/rejection_handled_web_process.ts)13
-rw-r--r--tests/specs/node/rejection_handled_web_process/rejection_handled_web_process.ts.out (renamed from tests/testdata/node/rejection_handled_web_process.ts.out)0
-rwxr-xr-xtools/lint.js2
5 files changed, 18 insertions, 12 deletions
diff --git a/tests/integration/node_unit_tests.rs b/tests/integration/node_unit_tests.rs
index a034897ef..b067f3121 100644
--- a/tests/integration/node_unit_tests.rs
+++ b/tests/integration/node_unit_tests.rs
@@ -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,
-});
diff --git a/tests/specs/node/rejection_handled_web_process/__test__.jsonc b/tests/specs/node/rejection_handled_web_process/__test__.jsonc
new file mode 100644
index 000000000..8f60df4f5
--- /dev/null
+++ b/tests/specs/node/rejection_handled_web_process/__test__.jsonc
@@ -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"
+}
diff --git a/tests/testdata/node/rejection_handled_web_process.ts b/tests/specs/node/rejection_handled_web_process/rejection_handled_web_process.ts
index a5136ca3d..c7957082f 100644
--- a/tests/testdata/node/rejection_handled_web_process.ts
+++ b/tests/specs/node/rejection_handled_web_process/rejection_handled_web_process.ts
@@ -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);
+});
diff --git a/tests/testdata/node/rejection_handled_web_process.ts.out b/tests/specs/node/rejection_handled_web_process/rejection_handled_web_process.ts.out
index e6fefede2..e6fefede2 100644
--- a/tests/testdata/node/rejection_handled_web_process.ts.out
+++ b/tests/specs/node/rejection_handled_web_process/rejection_handled_web_process.ts.out
diff --git a/tools/lint.js b/tools/lint.js
index aa3b417cc..d4fb4e9a0 100755
--- a/tools/lint.js
+++ b/tools/lint.js
@@ -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,