Skip to content

[Nexthop][bugfix] Fix race in ExpectSessionTest - #2000

Closed
andrew-nexthop wants to merge 1 commit into
meta:mainfrom
nexthop-ai:expect-session-test-race
Closed

andrew-nexthop wants to merge 1 commit into
meta:mainfrom
nexthop-ai:expect-session-test-race

Conversation

@andrew-nexthop

Copy link
Copy Markdown
Contributor

Pre-submission checklist

  • I've ran the linters locally and fixed lint errors related to the files I modified in this PR. You can install the linters by running pip install -r requirements-dev.txt && pre-commit install
  • pre-commit run

Summary

ExpectSessionTest.NoticesWhenChildExits and ExpectSessionTest.ChildReapedElsewhereIsNotAlive assert !isAlive() as soon as the session reaches EOF. The pty reports EOF when the child closes its terminal during exit, which can happen before the child is reapable, so waitpid(WNOHANG) still returns 0 and isAlive() is briefly true. This made NoticesWhenChildExits flaky in our CI. The tests now poll isAlive() until the child has been reaped, bounded by the existing 10s timeout.

Test Plan

Ran ExpectSessionTest suite repeatedly, before and after the fix, on an idle machine and with every CPU busy:

Failures Idle, 300 runs Every CPU busy, 100 runs
NoticesWhenChildExits 92 → 0 38 → 0
ChildReapedElsewhereIsNotAlive 6 → 0 11 → 0

Poll isAlive() until the child is reaped instead of asserting once at EOF.
@andrew-nexthop
andrew-nexthop requested a review from a team as a code owner November 16, 2026 15:07
@meta-cla meta-cla Bot added the CLA Signed label Nov 16, 2026
@github-actions github-actions Bot added nexthop project:bugfix FBOSS project: bugfix labels Nov 16, 2026
@andrew-nexthop

Copy link
Copy Markdown
Contributor Author

/autorebase

@meta-codesync

meta-codesync Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

@somasun has imported this pull request. If you are a Meta employee, you can view this in D132399699.

@meta-codesync meta-codesync Bot closed this in 2fee9ec Nov 17, 2026
@meta-codesync meta-codesync Bot added the Merged label Nov 17, 2026
@meta-codesync

meta-codesync Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

@somasun merged this pull request in 2fee9ec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants