Skip to content

Commit 426768d

Browse files
authored
Merge pull request #2530 from murgatroid99/benchmark_stop_delay
benchmark: Delay shutdown in quitWorker
2 parents 90adc8a + 1f08883 commit 426768d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

test/performance/driver.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ function main() {
7474
});
7575
serverWorkerStream.on('status', (status) => {
7676
console.log('Received server worker status ' + JSON.stringify(status));
77+
clientWorker.quitWorker({}, (error, response) => {
78+
if (error) {
79+
console.log('Received error on clientWorker.quitWorker:', error);
80+
} else {
81+
console.log('Received response from clientWorker.quitWorker');
82+
}
83+
});
84+
serverWorker.quitWorker({}, (error, response) => {
85+
if (error) {
86+
console.log('Received error on serverWorker.quitWorker:', error);
87+
} else {
88+
console.log('Received response from serverWorker.quitWorker');
89+
}
90+
});
7791
});
7892
}
7993

test/performance/worker_service_impl.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ module.exports = function WorkerServiceImpl(benchmark_impl, server) {
4141

4242
this.quitWorker = function quitWorker(call, callback) {
4343
callback(null, {});
44-
server.tryShutdown(function() {});
44+
/* Due to https://github.com/nodejs/node/issues/42713, tryShutdown acts
45+
* like forceShutdown on some Node versions. So, delay calling tryShutdown
46+
* until after done handling this request. */
47+
setTimeout(() => {
48+
server.tryShutdown(function() {});
49+
}, 10);
4550
};
4651

4752
this.runClient = function runClient(call) {

0 commit comments

Comments
 (0)