From eefd522f0490f9bb829de9342dcd1ed7aeacb42a Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Mon, 22 Feb 2021 00:21:25 +0800 Subject: fix(runtime/testing): false positive for timers when an error is thrown (#9553) --- runtime/js/40_testing.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'runtime/js') diff --git a/runtime/js/40_testing.js b/runtime/js/40_testing.js index 15545fc49..2258dc7b6 100644 --- a/runtime/js/40_testing.js +++ b/runtime/js/40_testing.js @@ -34,11 +34,14 @@ function assertOps(fn) { return async function asyncOpSanitizer() { const pre = metrics(); - await fn(); - // Defer until next event loop turn - that way timeouts and intervals - // cleared can actually be removed from resource table, otherwise - // false positives may occur (https://github.com/denoland/deno/issues/4591) - await delay(0); + try { + await fn(); + } finally { + // Defer until next event loop turn - that way timeouts and intervals + // cleared can actually be removed from resource table, otherwise + // false positives may occur (https://github.com/denoland/deno/issues/4591) + await delay(0); + } const post = metrics(); // We're checking diff because one might spawn HTTP server in the background // that will be a pending async op before test starts. -- cgit v1.2.3