Skip to content

fix(native): make Windows instance shutdown cancellable - #120

Draft
Milky2018 wants to merge 1 commit into
mainfrom
milky/fix-windows-app-instance-shutdown
Draft

fix(native): make Windows instance shutdown cancellable#120
Milky2018 wants to merge 1 commit into
mainfrom
milky/fix-windows-app-instance-shutdown

Conversation

@Milky2018

Copy link
Copy Markdown
Contributor

Background

The Windows native smoke test can occasionally hang until the CI timeout while destroying the primary application instance. Normal runs finish in well under a second, so this is a lifecycle race rather than expected test duration.

The Windows single-instance listener used synchronous named-pipe operations. Shutdown attempted to interrupt the listener with CancelSynchronousIo and then connected a temporary client to wake ConnectNamedPipe. There is a race where cancellation finds no pending I/O and the temporary connection happens before the listener creates its next pipe. The listener can then enter a new blocking ConnectNamedPipe call, while destruction waits indefinitely for that thread.

Changes

  • Open the server-side named pipe with FILE_FLAG_OVERLAPPED.
  • Make server-side connect, read, and write operations wait on both I/O completion and the instance stop_event.
  • Cancel and drain the exact pending overlapped operation when shutdown wins the wait.
  • Replace the blocking FlushFileBuffers step with an ACK receipt handshake so shutdown remains cancellable without risking premature disconnect.
  • Remove the racy CancelSynchronousIo and temporary-client wakeup path.

The public ABI and activation JSON format are unchanged.

Validation

  • moon fmt
  • moon info
  • cmake --build native/build-engine --config Debug
  • ctest --test-dir native/build-engine -C Debug --output-on-failure (6/6 passed)

The Windows-specific implementation cannot be executed on the current macOS host and requires Windows CI validation.

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