From e047225620d870b3d29824fadadd952fb4848463 Mon Sep 17 00:00:00 2001 From: Aapo Alasuutari Date: Sun, 26 Feb 2023 17:34:57 +0200 Subject: [PATCH] chore(ext/ffi): Use queueMicrotask in tests (#17954) --- test_ffi/tests/event_loop_integration.ts | 4 ++-- test_ffi/tests/thread_safe_test.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test_ffi/tests/event_loop_integration.ts b/test_ffi/tests/event_loop_integration.ts index 28152dabf1..55dc563bb5 100644 --- a/test_ffi/tests/event_loop_integration.ts +++ b/test_ffi/tests/event_loop_integration.ts @@ -29,7 +29,7 @@ const dylib = Deno.dlopen( let retry = false; const tripleLogCallback = () => { console.log("Sync"); - Promise.resolve().then(() => { + queueMicrotask(() => { console.log("Async"); callback.unref(); }); @@ -66,7 +66,7 @@ console.log("STORED_FUNCTION called"); // Wait to make sure synch logging and async logging await new Promise((res) => setTimeout(res, 100)); -// Ref once to make sure both `Promise.resolve().then()` and `setTimeout()` +// Ref once to make sure both `queueMicrotask()` and `setTimeout()` // must resolve and unref before isolate exists. // One ref'ing has been done by `threadSafe` constructor. callback.ref(); diff --git a/test_ffi/tests/thread_safe_test.js b/test_ffi/tests/thread_safe_test.js index c5e9c74b71..237a8d7130 100644 --- a/test_ffi/tests/thread_safe_test.js +++ b/test_ffi/tests/thread_safe_test.js @@ -82,7 +82,7 @@ const cleanupCallback = new Deno.UnsafeCallback( { parameters: [], result: "void" }, () => { console.log("Callback being called"); - Promise.resolve().then(() => cleanup()); + queueMicrotask(() => cleanup()); }, );