From 65a06eb6f94ba4d1683a907d741fa6334cc44036 Mon Sep 17 00:00:00 2001 From: Abdirahim Musse <33973272+abmusse@users.noreply.github.com> Date: Fri, 10 Mar 2023 11:48:17 -0600 Subject: [PATCH] test: close all connections to prevent server hang On IBM i calling server.close after the child process closes is not enough to end the server. For some reason the connection still lingers around with the server even though the process was closed. Calling closeAllConnections cleans up the lingering connection. Then calling server.close stops the server from listening for new connections and ends the server. On other platforms, closing the child client process causes the connection to close properly without having to call closeAllConnections. I ran this test case on Linux and AIX. This fix should help resolve the timeout in the following test case: - https://ci.nodejs.org/job/node-test-commit-ibmi/nodes=ibmi73-ppc64/1089/testReport/(root)/test/parallel_test_http_pipeline_flood/ --- test/parallel/test-http-pipeline-flood.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/parallel/test-http-pipeline-flood.js b/test/parallel/test-http-pipeline-flood.js index 29df81e857db60..0c5bd1dcd20de2 100644 --- a/test/parallel/test-http-pipeline-flood.js +++ b/test/parallel/test-http-pipeline-flood.js @@ -53,6 +53,15 @@ function parent() { const args = [__filename, 'child', this.address().port]; const child = spawn(process.execPath, args, { stdio: 'inherit' }); child.on('close', common.mustCall(function() { + if (common.isIBMi) { + // On IBM i calling server.close after the child process closes + // is not enough to end the server. For some reason the connection still + // lingers around with the server even though the process was closed. + // Calling closeAllConnections cleans up the lingering connection. + // Then calling server.close stops the server from listening + // for new connections and ends the server. + server.closeAllConnections(); + } server.close(); }));