Skip to content

Conversation

soulomoon
Copy link
Collaborator

gracefully exit the server

gracefully exit the server
@soulomoon soulomoon changed the title Fix broken pip during test Fix broken pipe during test Aug 22, 2025
@soulomoon
Copy link
Collaborator Author

Key idea:

  1. Wait for the refactor loop to finish in shutdown handler.
  2. After sending the shutdown response, stop sending further response to client. (This is done in lsp)

The worker thread checks this flag before dequeuing each job; if set, it exits immediately,
ensuring that no new work is started after shutdown is requested.
This mechanism is necessary because some downstream code may swallow async exceptions,
making 'cancel' unreliable for stopping the thread in all cases.
If 'cancel' does interrupt the thread (e.g., while blocked in STM or in a cooperative job),
the thread exits immediately and never checks the TMVar; in such cases, the stop flag is redundant.
@soulomoon soulomoon changed the title Fix broken pipe during test Fix broken pipe during test and gracefully exit the server Aug 26, 2025
@soulomoon soulomoon force-pushed the 1875-tests-randomly-fail-with-exception-fd111-hputbuf-resource-vanished-broken-pipe---test-option-j1-workaround branch from eb5356d to 773bfee Compare September 5, 2025 18:28
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.

Tests randomly fail with "Exception: fd:111: hPutBuf: resource vanished (Broken pipe)" (--test-option=-j1 workaround)
1 participant