mirror of
https://github.com/decolua/9router.git
synced 2026-05-08 12:01:28 +00:00
The ReadableStream cancel() callback is not reliably invoked on client disconnect under Next.js, causing emitter listeners (line/clear) and the keepalive interval to accumulate, eventually triggering MaxListenersExceededWarning. Use request.signal as the primary disconnect trigger, with cancel() and enqueue failures as fallbacks. Cleanup is idempotent via state.closed. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>