tearDownStdin (utils/stdin-teardown.ts)

n8n-mcp · src/utils/stdin-teardown.ts · typescript · MIT
infra, tag:knn-classified

Gracefully tears down stdin on shutdown, handling Windows edge cases.

// Source: https://github.com/czlonkowski/n8n-mcp | License: MIT | Copyright 2024 Romuald Czlonkowski @ www.aiadvisors.pl/en
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Platform-aware teardown of process.stdin during graceful shutdown.
 *
 * Issues #383 / #385: On Windows, calling `process.stdin.destroy()` while the
 * underlying libuv handle is already closing triggers a fatal assertion:
 *   Assertion failed: !(handle->flags & UV_HANDLE_CLOSING),
 *   file src\win\async.c, line 76
 * which crashes the MCP server on exit / client disconnect. `pause()` is safe
 * on every platform, so we always call it; we only `destroy()` off-Windows,
 * where the destroy releases the handle so the process can exit promptly.
 *
 * This helper ONLY handles pause/destroy. It does

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key