From 096a74735907c4f4d47aecfd4ef35c0f9bd2f542 Mon Sep 17 00:00:00 2001 From: Marly Fleitas Date: Tue, 11 May 2021 00:21:38 +0800 Subject: [PATCH] test: fix undoc assumptions about the timing of tsfn calls PR-URL: https://github.com/nodejs/node-addon-api/pull/995 Reviewed-By: Michael Dawson --- test/threadsafe_function/threadsafe_function.js | 8 +++----- .../typed_threadsafe_function.js | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/test/threadsafe_function/threadsafe_function.js b/test/threadsafe_function/threadsafe_function.js index 7da0e3d..5236f28 100644 --- a/test/threadsafe_function/threadsafe_function.js +++ b/test/threadsafe_function/threadsafe_function.js @@ -25,11 +25,9 @@ async function test(binding) { binding.threadsafe_function[threadStarter](function testCallback(value) { array.push(value); if (array.length === quitAfter) { - setImmediate(() => { - binding.threadsafe_function.stopThread(common.mustCall(() => { - resolve(array); - }), !!abort); - }); + binding.threadsafe_function.stopThread(common.mustCall(() => { + resolve(array); + }), !!abort); } }, !!abort, !!launchSecondary, maxQueueSize); if (threadStarter === 'startThreadNonblocking') { diff --git a/test/typed_threadsafe_function/typed_threadsafe_function.js b/test/typed_threadsafe_function/typed_threadsafe_function.js index 5d4a52a..51bbf2f 100644 --- a/test/typed_threadsafe_function/typed_threadsafe_function.js +++ b/test/typed_threadsafe_function/typed_threadsafe_function.js @@ -25,11 +25,9 @@ async function test(binding) { binding.typed_threadsafe_function[threadStarter](function testCallback(value) { array.push(value); if (array.length === quitAfter) { - setImmediate(() => { - binding.typed_threadsafe_function.stopThread(common.mustCall(() => { - resolve(array); - }), !!abort); - }); + binding.typed_threadsafe_function.stopThread(common.mustCall(() => { + resolve(array); + }), !!abort); } }, !!abort, !!launchSecondary, maxQueueSize); if (threadStarter === 'startThreadNonblocking') {