Skip to content

Fix server goroutine leak: add deadline to forwardRequest handshake#374

Merged
0pcom merged 1 commit intoskycoin:developfrom
0pcom:fix/forward-request-deadline
Apr 8, 2026
Merged

Fix server goroutine leak: add deadline to forwardRequest handshake#374
0pcom merged 1 commit intoskycoin:developfrom
0pcom:fix/forward-request-deadline

Conversation

@0pcom
Copy link
Copy Markdown
Collaborator

@0pcom 0pcom commented Apr 8, 2026

Summary

Add HandshakeTimeout deadline to forwardRequest's readObject call.

Root cause

forwardRequest opens a yamux stream to the destination visor and reads the handshake response. If the destination accepts the stream but never responds (dead visor, stuck process), readObject blocks forever. Observed as 2,400+ stuck goroutines per DMSG server minutes after restart.

The idle timeout fix (PR #372) only covered the bridge phase after handshake completion. The forwardRequest handshake itself had no timeout.

Fix

Set HandshakeTimeout deadline before write/read, clear it after handshake completes (before returning the stream for long-lived bridging).

forwardRequest opens a stream to the destination and reads the
response. If the destination accepts but never responds, readObject
blocks forever — observed as 2.4K+ stuck goroutines per server,
growing rapidly after restart.

The idle timeout fix (PR skycoin#372) only covered the bridge phase
(CopyReadWriteCloser). This adds HandshakeTimeout to the
forwardRequest handshake read, matching the client-side behavior.
@0pcom 0pcom merged commit 9dddab0 into skycoin:develop Apr 8, 2026
3 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.

1 participant