github remix-run/remix node-fetch-server@1.1.0
node-fetch-server v1.1.0

one hour ago

Minor Changes

  • Start Node.js HTTP and HTTPS servers with managed socket lifecycle and graceful shutdown using the new serve() helper, modeled after Bun.serve(). Calling server.stop() stops accepting new connections, closes idle and speculative zero-byte TCP/TLS sockets immediately, and waits for in-flight requests to finish; calling server.stop(true) closes all active connections immediately or escalates an in-progress graceful stop. (#12491)

    import * as fs from 'node:fs'
    import { serve } from '@remix-run/node-fetch-server'
    
    let server = await serve({
      port: 3000,
      fetch(request) {
        return new Response(`Hello from ${new URL(request.url).pathname}`)
      },
    })
    
    // Graceful drain, or pass `true` to close active connections immediately
    await server.stop()
    
    // Pass `tls` options to serve over HTTPS using `node:https`
    let secureServer = await serve({
      port: 443,
      fetch(request) {
        return new Response(`Secure: ${request.url}`)
      },
      tls: {
        key: fs.readFileSync('private-key.pem'),
        cert: fs.readFileSync('certificate.pem'),
      },
    })

    createTestServer() in @remix-run/node-fetch-server/test now uses serve() under the hood so test servers close lingering connections immediately on teardown.

Patch Changes

  • HTTP/2 responses now omit connection-specific headers, including fields named by Connection within the same set of response headers. If the request listener cannot send an error response, it logs the write failure and closes the affected response. (#12484)

  • Improve request and response handling throughput in createRequestListener(), createRequest(), and sendResponse(). As part of this change, sendResponse() no longer releases its reader lock on the consumed response.body stream after writing, bodyless HTTP/1.x requests (with Content-Length: 0 or neither Content-Length nor Transfer-Encoding) now leave request.body as null instead of wrapping an empty stream, and createRequestListener() now always constructs and passes a Request to handlers with .length === 0 (such as rest-parameter handlers) and routes their errors through onError consistently with other handlers. (#12450)

  • Reject incoming requests with a literal backslash (\) in the URL path. createRequestListener() responds with 400 Bad Request unless onError returns a custom response, and createRequest() throws. Percent-encoded backslashes (%5C) and backslashes in the query string are still accepted. (#12368)

  • Finish single-chunk responses that include a matching Content-Length header directly with res.end(chunk) instead of calling res.write() followed by a separate res.end(). (#12463)

Don't miss a new remix release

NewReleases is sending notifications on new releases.