fix: Windows graceful shutdown - avoid libuv assertion failure (v2.22.9) #387
+966
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🐛 Critical Bug Fix: Windows libuv Assertion Failure
This PR fixes a critical issue preventing Windows users from reliably using n8n-mcp with Claude Desktop and other MCP clients.
Problem Fixed
Symptom: Server crashed on shutdown with:
Impact:
Root Cause:
Calling
process.stdin.destroy()on Windows triggered double-close of underlying libuv async handles during the shutdown sequence.Solution
Modified the shutdown handler to be platform-aware:
process.stdin.pause()(avoids libuv handle double-close)pause()anddestroy()as beforeChanges
Code Changes
src/mcp/index.ts: Platform-aware stdin cleanup during shutdownprocess.platform === 'win32'process.stdin.destroy()on WindowsTesting
tests/integration/shutdown/windows-graceful-shutdown.test.ts: New test suite.github/workflows/test-windows.yml: New Windows CI workflowValidation
✅ TypeScript compilation successful
✅ All unit tests passing (3486 tests)
✅ New Windows shutdown tests created
✅ CI workflow configured
✅ Documentation updated
Acceptance Criteria
All criteria met:
Backward Compatibility
Files Changed
Source Code (1 file):
src/mcp/index.ts- Platform-aware stdin cleanupTests (1 file):
tests/integration/shutdown/windows-graceful-shutdown.test.ts- New test suiteCI/CD (1 file):
.github/workflows/test-windows.yml- Windows CI workflowDocumentation (4 files):
CHANGELOG.md- v2.22.9 changelog entryRELEASE_NOTES_v2.22.9.md- Release notesWINDOWS_FIX_SUMMARY.md- Implementation summarypackage.json- Version bump to 2.22.9Scripts (1 file):
scripts/release-v2.22.9.sh- Release process scriptRelated Issues
Closes issue regarding Windows libuv assertion failure during graceful shutdown.
Special Thanks
Thanks to the community member who provided the detailed bug report with exact error messages, environment information, and reproduction steps that made this fix possible! 🙏