Report server exit code instead of pipe error

When the node server exits early, writing its config to the dead stdin
raised BrokenPipeError (EINVAL on Windows), burying the real cause.
communicate() ignores both, so the underlying failure stays visible.

Refs #656
This commit is contained in:
Pratyush Sharma
2026-07-15 18:31:52 +05:30
parent 5bf8081aec
commit 84fadb7481
+7 -8
View File
@@ -63,13 +63,12 @@ def launch_server(**kwargs) -> NoReturn:
stdin=subprocess.PIPE,
text=True,
)
# Write data to stdin and close the stream
if process.stdin:
process.stdin.write(base64.b64encode(data).decode())
process.stdin.close()
# Wait forever
process.wait()
# Write data to stdin, close the stream, and wait forever.
# communicate() tolerates the pipe closing early if the server exits before reading
# its config, keeping that error visible instead of masking it with an OSError.
process.communicate(input=base64.b64encode(data).decode())
# Add an explicit return statement to satisfy the NoReturn type hint
raise RuntimeError("Server process terminated unexpectedly")
raise RuntimeError(
f"Server process terminated unexpectedly with exit code {process.returncode}"
)