Duplicate transfer-encoding header when using multipart/mixed with uWebSockets.js

Author: mattkrickCreated Mar 24, 2026Updated Mar 24, 2026

Describe the bug

uWebSockets.js writes the header transfer-encoding=chunked when it sees write + end. https://github.com/uNetworking/uWebSockets.js/issues/1169#issuecomment-2849396067

graphql-yoga also writes transfer-encoding=chunked when sending a multipart/mixed response: https://github.com/graphql-hive/graphql-yoga/blob/19fc65ab563c39ec0bda61ff24a72821289c3fd4/packages/graphql-yoga/src/plugins/result-processor/multipart.ts#L14

together, this results in transfer-encoding=chunked, chunked. While incorrect, this is tolerated by most browser clients. Unfortunately, it is not tolerated by load balancers (specifically Google Compute Load Balancer). The result is a 502 at the load balancer (and me digging through my helm charts to see where I went wrong )

Yoga is great, it's easy enough to fix this with a plugin:

typescript
export const useRemoveDuplicateTransferEncoding: Plugin<ServerContext> = {
  onResponse({response}) {
    const transferEncoding = response.headers.get('transfer-encoding')
    if (transferEncoding === 'chunked') {
      response.headers.delete('transfer-encoding')
    }
  }
}

However, knowing that this is necessary is the battle. It looks like one of yoga's goals is to support uWebSockets.js out of the box:

Since GraphQL Yoga is framework and environment agnostic, it supports µWebSockets.js out of the box with a simple configuration.

For this reason, I think if the server is uWebSockets.js, yoga's multipart.ts should exclude writing the transfer-encoding header. Alternatively, some documentation on the uWebSockets page would also work!

Your Example Website or App

n/a

Steps to Reproduce the Bug or Issue

Use the @defer directive to trigger a multipart response. Verify the response header transfer-encoding=chunked, chunked

Expected behavior

The header should only be set once: transfer-encoding=chunked

Screenshots or Videos

No response

Platform

Platform agnostic "graphql-yoga": "^5.15.2"

Additional context

No response

Source: graphql-hive/graphql-yoga