Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix broken pipe during test and gracefully exit the server #4701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
soulomoon wants to merge 64 commits into master
base: master
Choose a base branch
Loading
from 1875-tests-randomly-fail-with-exception-fd111-hputbuf-resource-vanished-broken-pipe---test-option-j1-workaround

Conversation

Copy link
Collaborator

@soulomoon soulomoon commented Aug 21, 2025

gracefully exit the server

fendor reacted with heart emoji
gracefully exit the server
@soulomoon soulomoon changed the title (削除) Fix broken pip during test (削除ここまで) (追記) Fix broken pipe during test (追記ここまで) Aug 22, 2025
soulomoon added 12 commits August 22, 2025 08:35
...111-hputbuf-resource-vanished-broken-pipe---test-option-j1-workaround
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
Copy link
Collaborator Author

soulomoon commented Sep 18, 2025
edited
Loading

What's been done

  1. Refactor exit logic

    • Previously, shutdown and Shake database cleanup only happened in the shutdown handler.
    • Now, the cleanup is moved into the finally clause of the reactor thread, ensuring it always runs on reactor exit.
    • Also adapted to a modified LSP package branch so the server can now gracefully exit. Gracefully exit the server lsp#622 (comment)
  2. Improve logging

    • Added clearer and more structured logging to aid debugging.
  3. Add flakiness testing support

    • Introduced a flakiness testing script and CI integration.
    • Makes it easier to detect and diagnose flaky behavior in development and CI runs.

@soulomoon soulomoon marked this pull request as ready for review September 18, 2025 12:45
@soulomoon soulomoon added the status: needs review This PR is ready for review label Sep 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@michaelpj michaelpj Awaiting requested review from michaelpj michaelpj is a code owner

@fendor fendor Awaiting requested review from fendor fendor is a code owner

@jian-lin jian-lin Awaiting requested review from jian-lin jian-lin is a code owner

@wz1000 wz1000 Awaiting requested review from wz1000 wz1000 is a code owner

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
status: needs review This PR is ready for review
Projects
None yet
Milestone
No milestone
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

AltStyle によって変換されたページ (->オリジナル) /