Skip to content

[2.x] fix: Prevent server subprocess hang on Linux (#8442)#8494

Merged
eed3si9n merged 1 commit intosbt:developfrom
calm329:fix/8442-server-subprocess-hang-linux
Jan 12, 2026
Merged

[2.x] fix: Prevent server subprocess hang on Linux (#8442)#8494
eed3si9n merged 1 commit intosbt:developfrom
calm329:fix/8442-server-subprocess-hang-linux

Conversation

@calm329
Copy link
Copy Markdown
Contributor

@calm329 calm329 commented Jan 12, 2026

Summary

  • Fix hang when sbt client spawns server subprocess on Linux
  • When the server is forked with --detach-stdio, stdout/stderr now redirect to DISCARD instead of inheriting from parent
  • On Linux, inherited pipes have ~64KB buffers that block writes when full, causing the server to hang during initialization (e.g., when printing lint warnings for projects with 45+ subprojects)

Root Cause

When NetworkClient.waitForServer spawns the server process:

  1. stdout/stderr were inherited from the parent process
  2. The client communicates with the server via socket, never consuming stdout/stderr
  3. On Linux, once the pipe buffer fills (~64KB), FileOutputStream.writeBytes blocks indefinitely
  4. This caused the server to hang before creating active.json

Workarounds that worked (confirming the diagnosis):

  • --debug flag (affects logging behavior)
  • -Dsbt.log.noformat=true (reduces output volume)

Fix

Add .redirectOutput(Redirect.DISCARD).redirectError(Redirect.DISCARD) to the ProcessBuilder, which redirects to /dev/null on Unix.

Test plan

  • Code compiles successfully
  • Verified client doesn't read from process stdout/stderr (communicates via socket)
  • Manual test on Linux with 45+ subproject build (cannot reproduce on macOS due to different pipe buffering)

Fixes #8442


Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=148254234

@calm329 calm329 force-pushed the fix/8442-server-subprocess-hang-linux branch from de8cf7e to 476730a Compare January 12, 2026 05:02
Copy link
Copy Markdown
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@eed3si9n eed3si9n merged commit 88812f2 into sbt:develop Jan 12, 2026
14 checks passed
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.

[2.x] hang when trying to start a new server subprocess

2 participants