Skip to content

bug: write method is not returning a boolean value #683

Closed

Description

@realityfilter

The implementation of the write method is missing a boolean return value indicating the need of drain https://github.com/CodeGenieApp/serverless-express/blob/mainline/src/response.js.

See https://nodejs.org/api/stream.html#writablewritechunk-encoding-callback

'The return value is true if the internal buffer is less than the highWaterMark configured when the stream was created after admitting chunk. If false is returned, further attempts to write data to the stream should stop until the 'drain' event is emitted.'

With newer versions of trpc (11.0.0-rc.419) this leads to a hang. The trpc middleware interprets void as false and waits for the 'drain' event that is never showing up. The lambda runtime is shutting down the event handling with an internal server error.

See https://github.com/trpc/trpc/blob/fbb4a2fb4b71d2f5ab7ee97617d951f3a92517c8/packages/server/src/adapters/node-http/nodeHTTPRequestHandler.ts#L85

In response.js the write method should return true.

See https://github.com/realityfilter/serverless-express-write-bugreport
for a test case.

Activity

  1. KATT commented on Jul 4, 2024

    @KATT

    This might be enough? KATT@9ba260e

  2. jimdigriz commented on Jul 3, 2025

    @jimdigriz
    Contributor

    Ran into this problem when packaging SvelteKit with adapter-node and polka, the effect confusingly caused the Lambda to return status code 200 with null as the body.

    I can confirm that @KATT's fix provided does work, thanks!

  3. joshlperry commented on Jul 10, 2025

    @joshlperry

    Ran into this problem when trying to upgrade to Next.js 14.0.0. It also interprets void as falsey and waits for the stream 'drain' event that never happens. Patching my serverless-express version with this fix, solved the problem 👍

  4. joshlperry commented on Jul 10, 2025

    @joshlperry

    @brettstack Could we get @KATT's fix in?

  5. brettstack commented on Jul 11, 2025

    @brettstack
    Collaborator

    If someone wants to submit this as a PR I can merge it in @joshlperry @KATT

  6. joshlperry commented on Jul 17, 2025

    @joshlperry

    @brettstack I tried to make a PR originally but I lacked permissions and couldn't push up to create a remote branch, did I miss something? Happy to create a PR

  7. added a commit that references this issue on Aug 4, 2025
    9e024f4
  8. added a commit that references this issue on Dec 7, 2025
    d9be538
  9. github-actions commented on Dec 8, 2025

    @github-actions

    🎉 This issue has been resolved in version 4.17.2-beta.1 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

  10. github-actions commented on Dec 8, 2025

    @github-actions

    🎉 This issue has been resolved in version 5.0.0-beta.1 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

  11. added a commit that references this issue on Apr 16, 2026
  12. github-actions commented on Apr 16, 2026

    @github-actions

    🎉 This issue has been resolved in version 5.0.0 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions