-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
needs triageThis issue has not been looked intoThis issue has not been looked into
Description
Bug Report
Transfer-Encoding likely should be set to "chunked", if I understand correctly. This only seems to be an issue when running behind particular reverse-proxies. As of RFC 7230, "identity" is not a thing anymore, and we are probably off-spec for any other value. nginx only supports "chunked" anyway.
In my particular case, NestJS application running behind Traefik, this results in the following error net/http: HTTP/1.x transport connection broken: unsupported transfer encoding: identity
Possible Solution
nest/packages/core/router/sse-stream.ts
pipe<T extends HeaderStream>(destination: T, options?: { end?: boolean }): T {
if (destination.writeHead) {
destination.writeHead(200, {
// See https://github.com/dunglas/mercure/blob/master/hub/subscribe.go#L124-L130
'Content-Type': 'text/event-stream',
Connection: 'keep-alive',
// Disable cache, even for old browsers and proxies
'Cache-Control':
'private, no-cache, no-store, must-revalidate, max-age=0, no-transform',
'Transfer-Encoding': 'identity',
Pragma: 'no-cache',
Expire: '0',
// NGINX support https://www.nginx.com/resources/wiki/start/topics/examples/x-accel/#x-accel-buffering
'X-Accel-Buffering': 'no',
});
destination.flushHeaders();
}
destination.write(':\n');
return super.pipe(destination, options);
}
Replace "identity" with "chunked"
Environment
- Nest version: 7.6.15
- Node version: 15.14.0
- Platform: Linux
Metadata
Metadata
Assignees
Labels
needs triageThis issue has not been looked intoThis issue has not been looked into