mirror of
https://github.com/daijro/camoufox.git
synced 2026-08-19 08:01:00 +00:00
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:
@@ -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}"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user