#5546·atproto

lex-server/nodejs: completing a POST body aborts request.signal before the response

Author: KzoepsCreated Sep 24, 2026Updated Sep 24, 2026

Package

@atproto/lex-server/nodejs 0.1.9 and 0.1.19 (Node.js 24). The current packages/lex/lex-server/src/nodejs.ts also attaches abort to req.on('end', abort) in requestSignal().

Reproduction

javascript
import { createServer } from '@atproto/lex-server/nodejs'

const server = createServer({
  fetch: async (request) => {
    const before = request.signal.aborted
    await request.text()
    return Response.json({ before, after: request.signal.aborted })
  },
})
server.listen(3000)

Send a normal POST with a complete body:

bash
curl -sS -X POST http://localhost:3000/xrpc/test \
  -H 'content-type: application/json' --data '{}'

Actual: {"before":false,"after":true}. Expected: the signal remains live while the response is being processed; completion of the request body is not a client disconnect.

IncomingMessage emits end after a successful body read. This invokes abort() in requestSignal(), even though the connection remains open for the response. In an XRPC app that bounds/buffers the POST body before passing it to LexRouter, serviceAuth() subsequently resolves the issuer DID with this already-aborted signal. The router then returns HTTP 499 {"error":"RequestAborted"} for a valid signed JWT. A malformed JWT returns 401 before DID resolution, so this is easy to miss in unit tests using synthetic Request objects. Since the router treats this as a request abort, the application's error hook is not called.

Please keep normal full-body completion distinct from a genuine client disconnect, and add a Node HTTP test that checks the signal after a complete POST body is read.