From f526513d74d34ac254aa40ef9b73238cb21c395b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 28 Nov 2022 23:07:23 +0100 Subject: feat(core): show unresolved promise origin (#16650) This commit updates unhelpful messages that are raised when event loop stalls on unresolved top-level promises. Instead of "Module evaluation is still pending but there are no pending ops or dynamic imports. This situation is often caused by unresolved promises." and "Dynamically imported module evaluation is still pending but there are no pending ops. This situation is often caused by unresolved promises." we are now printing a message like: error: Top-level await promise never resolved [SOURCE LINE] ^ at [FUNCTION NAME] ([FILENAME]) eg: error: Top-level await promise never resolved await new Promise((_resolve, _reject) => {}); ^ at (file:///Users/ib/dev/deno/cli/tests/testdata/test/unresolved_promise.ts:1:1) Co-authored-by: David Sherret --- cli/tests/testdata/bench/unresolved_promise.out | 5 ++++- cli/tests/testdata/run/top_level_await/circular.out | 7 ++++--- cli/tests/testdata/run/top_level_await/unresolved.out | 5 ++++- cli/tests/testdata/test/unresolved_promise.out | 15 ++++++++++----- 4 files changed, 22 insertions(+), 10 deletions(-) (limited to 'cli/tests/testdata') diff --git a/cli/tests/testdata/bench/unresolved_promise.out b/cli/tests/testdata/bench/unresolved_promise.out index d544d77e7..b601e9b70 100644 --- a/cli/tests/testdata/bench/unresolved_promise.out +++ b/cli/tests/testdata/bench/unresolved_promise.out @@ -1,2 +1,5 @@ Check [WILDCARD]/bench/unresolved_promise.ts -error: Module evaluation is still pending but there are no pending ops or dynamic imports. This situation is often caused by unresolved promises. +error: Top-level await promise never resolved +await new Promise((_resolve, _reject) => {}); +^ + at ([WILDCARD]bench/unresolved_promise.ts:1:1) diff --git a/cli/tests/testdata/run/top_level_await/circular.out b/cli/tests/testdata/run/top_level_await/circular.out index 72072071e..c88978961 100644 --- a/cli/tests/testdata/run/top_level_await/circular.out +++ b/cli/tests/testdata/run/top_level_await/circular.out @@ -4,6 +4,7 @@ timeout loop 2 timeout loop 3 timeout loop 4 timeout loop 5 -error: Dynamically imported module evaluation is still pending but there are no pending ops. This situation is often caused by unresolved promises. -Pending dynamic modules: -- [WILDCARD]/tla3/b.js +error: Top-level await promise never resolved +const mod = await import("./tla3/b.js"); + ^ + at ([WILDCARD]/top_level_await/circular.js:5:13) diff --git a/cli/tests/testdata/run/top_level_await/unresolved.out b/cli/tests/testdata/run/top_level_await/unresolved.out index d5291f833..1f4ea5d38 100644 --- a/cli/tests/testdata/run/top_level_await/unresolved.out +++ b/cli/tests/testdata/run/top_level_await/unresolved.out @@ -1 +1,4 @@ -error: Module evaluation is still pending but there are no pending ops or dynamic imports. This situation is often caused by unresolved promises. +error: Top-level await promise never resolved +await new Promise(() => {}); +^ + at ([WILDCARD]top_level_await/unresolved.js:1:1) diff --git a/cli/tests/testdata/test/unresolved_promise.out b/cli/tests/testdata/test/unresolved_promise.out index 92eb16bed..88535e171 100644 --- a/cli/tests/testdata/test/unresolved_promise.out +++ b/cli/tests/testdata/test/unresolved_promise.out @@ -1,5 +1,10 @@ -Check [WILDCARD]/test/unresolved_promise.ts - -ok | 0 passed | 0 failed ([WILDCARD]) - -error: Module evaluation is still pending but there are no pending ops or dynamic imports. This situation is often caused by unresolved promises. +[WILDCARD] +./test/unresolved_promise.ts (uncaught error) +error: Top-level await promise never resolved +await new Promise((_resolve, _reject) => {}); +^ + at ([WILDCARD]/test/unresolved_promise.ts:1:1) +This error was not caught from a test and caused the test runner to fail on the referenced module. +It most likely originated from a dangling promise, event/timeout handler or top-level code. +[WILDCARD] +error: Test failed -- cgit v1.2.3