Skip to content

Commit

Permalink
fix: fixed hanging servers on test errors
Browse files Browse the repository at this point in the history
We were returning non-zero exit codes before killing the server. 🤦
  • Loading branch information
arctic-hen7 committed Feb 5, 2023
1 parent c3c575b commit 2ad8bea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
12 changes: 0 additions & 12 deletions docs/next/en-US/fundamentals/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <pid-here>`.

Please note that this is considered a bug, but it's a known one, and it will be addressed soon!
7 changes: 4 additions & 3 deletions packages/perseus-cli/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2ad8bea

Please sign in to comment.