Skip to content

Avoid double-sending Fastify replies in @orpc/nest#1558

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-fst-err-rep-already-sent
Draft

Avoid double-sending Fastify replies in @orpc/nest#1558
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-fst-err-rep-already-sent

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 18, 2026

Using @orpc/nest with Nest's FastifyAdapter could trigger FST_ERR_REP_ALREADY_SENT on successful oRPC routes. The response was being written by oRPC and then sent again by Nest's normal Fastify response pipeline.

  • Fastify response handling

    • Change the default Fastify path in ImplementInterceptor to prepare the reply on FastifyReply and return the serialized body to Nest, instead of calling sendStandardResponse(...) directly.
    • Preserve existing behavior for:
      • Express
      • Hono
      • custom sendResponseInterceptors that intentionally take over response sending/return behavior
  • Regression coverage

    • Extend the existing Nest/Fastify integration test to capture Fastify logs and assert the request completes without the Reply was already sent warning.
    • Keep the existing assertions around response status, body, and headers to ensure compatibility with current route behavior.
  • Behavioral impact

    • Default @Implement(...) routes on Fastify now flow through a single send path.
    • Fastify-specific reply state such as status and headers is still applied before Nest sends the response.
// before
await StandardServerFastify.sendStandardResponse(reply, standardResponse, config)
// Nest would later call reply.send(...) again

// after
reply
  .status(standardResponse.status)
  .headers(StandardServerNode.toNodeHttpHeaders(headers))

return body
// Nest performs the single send

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 18, 2026

Deploying orpc with  Cloudflare Pages  Cloudflare Pages

Latest commit: b85f218
Status: ✅  Deploy successful!
Preview URL: https://503a57d4.orpc-4zt.pages.dev
Branch Preview URL: https://copilot-fix-fst-err-rep-alre.orpc-4zt.pages.dev

View logs

Copilot AI changed the title [WIP] Fix FST_ERR_REP_ALREADY_SENT for Nest with FastifyAdapter Avoid double-sending Fastify replies in @orpc/nest May 18, 2026
Copilot AI requested a review from dinwwwh May 18, 2026 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FST_ERR_REP_ALREADY_SENT on Nest with FastifyAdapter

2 participants