Skip to content

Fix truncated messages at the end of test runs - #682

Merged
lydell merged 4 commits into
masterfrom
fix-truncated-messages
Aug 1, 2026
Merged

Fix truncated messages at the end of test runs#682
lydell merged 4 commits into
masterfrom
fix-truncated-messages

Conversation

@lydell

@lydell lydell commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

I noticed that when running a big test suite with intellij-elm, a successful test run wasn’t reported as successful, but as “Terminated”. I first thought this was a bug in intellij-elm, but it turned out to be a bug in node-test-runner.

The reason some tests were marked as “Terminated” was because they never got their "testCompleted" message. intellij-elm then interprets this as the test never finished and was terminated. What actually happened was that those test did complete, and node-test-runner did print the messages, but it then exited the process before everything had time to flush. This is a classic gotcha in Node.js: If you do console.log(somethingLong); process.exit(0); then somethingLong can be truncated mid-way.

Each worker buffers test successes and sends them in batches in order to optimize for the fewest IPC messages. For a successful test run, it means that each worker sends one, single, big batch of "testCompleted" at the end, once the worker has finished running all its tests. The main process then prints all of those and exits.

This PR fixes this issue by using the approach usually recommended in this case: console.log(somethingLong); process.exitCode = 0;. Instead of exiting the process explicitly and forcefully, we let it exit by itself once the event loop runs out. This required explicitly closing the server in Supervisor.js (otherwise it kept on listening forever), and terminating the worker_threads worker used to make synchronous HTTP requests for elm-solve-deps-wasm. The latter one was a “hidden dependency,” so it required a bit more work. I now pass it down all the way from the top, making it easy to know when to clean it up.

I have tested this with the big test suite and intellij-elm: With this PR applied the test suite is marked as successful, not “Terminated”.

I went through all the place we call process.exit. Most of them do so after printing something short, so I didn’t touch them, because I didn’t want to risk the process not exiting in those case due to something not being shut down. The only other place I found that we might print something long before exiting is elm-test make, so I updated that to use the process.exitCode strategy as well (for elm make errors, not unknown errors).

@lydell
lydell force-pushed the fix-truncated-messages branch from c0fd040 to 1ab6a3b Compare August 1, 2026 11:47
@lydell
lydell force-pushed the fix-truncated-messages branch 3 times, most recently from 3f3016e to b285cfb Compare August 1, 2026 16:46
@lydell
lydell force-pushed the fix-truncated-messages branch from b285cfb to efd8fb9 Compare August 1, 2026 16:48
@lydell
lydell merged commit 8ee795a into master Aug 1, 2026
13 checks passed
@lydell
lydell deleted the fix-truncated-messages branch August 1, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant