From 2ad8bea273fc5a8846f4ec788afcda01573e24be Mon Sep 17 00:00:00 2001 From: arctic-hen7 Date: Sun, 5 Feb 2023 15:30:30 +1100 Subject: [PATCH] fix: fixed hanging servers on test errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We were returning non-zero exit codes before killing the server. 🤦 --- docs/next/en-US/fundamentals/testing.md | 12 ------------ packages/perseus-cli/src/test.rs | 7 ++++--- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/docs/next/en-US/fundamentals/testing.md b/docs/next/en-US/fundamentals/testing.md index 483e124243..597570bad1 100644 --- a/docs/next/en-US/fundamentals/testing.md +++ b/docs/next/en-US/fundamentals/testing.md @@ -60,15 +60,3 @@ It is entirely permissible, and indeed encouraged, for apps that have more advan Common uses of custom checkpoints are particularly when combined with the [suspended state](:state/suspense) system, if some of your pages fetch state on the client-side, and you want to test for that all working correctly. If a checkpoint is not emitted, tests waiting for it will fail with a timeout error. - -## Hanging servers - -Note that *some* critical errors during testing will lead to process termination in such a way that Perseus sometimes won't catch the child process failure correctly, which may lead to a server being left open on your computer. These are easy to terminate manually though: on Linux you might do this: - -``` -netstat -lnp | grep 8080 -``` - -You would replace `8080` with whatever port you're running the tests on, and then this should list a PID that you can kill with `kill `. - -Please note that this is considered a bug, but it's a known one, and it will be addressed soon! diff --git a/packages/perseus-cli/src/test.rs b/packages/perseus-cli/src/test.rs index 3ee9fbf14a..c1331b1948 100644 --- a/packages/perseus-cli/src/test.rs +++ b/packages/perseus-cli/src/test.rs @@ -131,14 +131,15 @@ pub fn test( let test_res = test_thread .join() .map_err(|_| ExecutionError::ThreadWaitFailed)??; - if test_res != 0 { - return Ok(test_res); - } // If the server has already terminated, it had an error, and that would be // reflected in the tests let _ = server.kill(); + if test_res != 0 { + return Ok(test_res); + } + // We've handled errors in the component threads, so the exit code is now zero Ok(0) } else {