mirror of
https://github.com/supabase/supabase.git
synced 2026-10-10 11:55:05 +03:00
Pages-router handlers that stream (e.g. /api/ai/sql/generate-v4)
wire client-abort by subscribing to Node IncomingMessage events:
const abortController = new AbortController()
req.on('close', () => abortController.abort())
req.on('aborted', () => abortController.abort())
The toWebHandler shim built a plain NextApiRequest-shaped object with
no EventEmitter surface, so those calls crashed at runtime with
'req.on is not a function' on every request.
Surface a minimal EventEmitter (on/off/once/emit/removeListener/
removeAllListeners) that only honours the two events studio actually
uses ('close', 'aborted'), both wired to request.signal's abort
event. Other event names are accepted but never fire - good enough
for the handlers we forward through this shim.