From 1f08883e2aded2276a877edfb16ba3daa4b339bf Mon Sep 17 00:00:00 2001 From: Michael Lumish Date: Mon, 31 Jul 2023 10:50:28 -0700 Subject: [PATCH] benchmark: Delay shutdown in quitWorker --- test/performance/driver.js | 14 ++++++++++++++ test/performance/worker_service_impl.js | 7 ++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/test/performance/driver.js b/test/performance/driver.js index fa0e87560..9ecc4bc21 100644 --- a/test/performance/driver.js +++ b/test/performance/driver.js @@ -74,6 +74,20 @@ function main() { }); serverWorkerStream.on('status', (status) => { console.log('Received server worker status ' + JSON.stringify(status)); + clientWorker.quitWorker({}, (error, response) => { + if (error) { + console.log('Received error on clientWorker.quitWorker:', error); + } else { + console.log('Received response from clientWorker.quitWorker'); + } + }); + serverWorker.quitWorker({}, (error, response) => { + if (error) { + console.log('Received error on serverWorker.quitWorker:', error); + } else { + console.log('Received response from serverWorker.quitWorker'); + } + }); }); } diff --git a/test/performance/worker_service_impl.js b/test/performance/worker_service_impl.js index a73d77efc..30016aa71 100644 --- a/test/performance/worker_service_impl.js +++ b/test/performance/worker_service_impl.js @@ -41,7 +41,12 @@ module.exports = function WorkerServiceImpl(benchmark_impl, server) { this.quitWorker = function quitWorker(call, callback) { callback(null, {}); - server.tryShutdown(function() {}); + /* Due to https://github.com/nodejs/node/issues/42713, tryShutdown acts + * like forceShutdown on some Node versions. So, delay calling tryShutdown + * until after done handling this request. */ + setTimeout(() => { + server.tryShutdown(function() {}); + }, 10); }; this.runClient = function runClient(call) {