You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a server sends a Trailer: X header, it's saying that it may send an X trailer field after the response. Undici treats this as a commitment, and throws an error if the response has no such trailer, for no apparent reason.
This seems to be an intentional check here discussed originally in #432. There's no reference to any spec there that says this is necessary though (and I can't find one) just discussion suggesting maybe it's odd. Undici should follow the spec, not reject responses that seem weird.
There are real servers (e.g. all IPFS nodes, as noted in that issue at the time) that are broken by this in many cases, since they return trailer: X-Stream-Error with all streaming responses, to indicate that they may add stream errors after the body in some cases.
Browser fetch & node HTTP don't enforce this, and no spec says this is invalid - this check should just be removed imo.
Reproducible By
consthttp=require('http');http.createServer((req,res)=>{res.writeHead(200,{trailer: 'test'});res.end('body');}).listen(8008);// Global Undici fetch from Node 18:fetch('http://localhost:8008').then((res)=>{console.log('got status',res.status);returnres.text();}).then((body)=>{console.log('got body',body);}).catch(console.error);
Bug Description
When a server sends a
Trailer: X
header, it's saying that it may send anX
trailer field after the response. Undici treats this as a commitment, and throws an error if the response has no such trailer, for no apparent reason.This seems to be an intentional check here discussed originally in #432. There's no reference to any spec there that says this is necessary though (and I can't find one) just discussion suggesting maybe it's odd. Undici should follow the spec, not reject responses that seem weird.
There are real servers (e.g. all IPFS nodes, as noted in that issue at the time) that are broken by this in many cases, since they return
trailer: X-Stream-Error
with all streaming responses, to indicate that they may add stream errors after the body in some cases.Browser fetch & node HTTP don't enforce this, and no spec says this is invalid - this check should just be removed imo.
Reproducible By
This prints:
Expected Behavior
This should work as normal, as if the
trailer
field was not present.This works correctly in Node HTTP, node-fetch & browser fetch, so this produces regressions for everybody using a fetch polyfill with Node 18.
Environment
Ubuntu 20.04, using global from Node 18.0.0 or Node 16.14.2 with Undici 5.1.1.
Additional context
Looks like this was causing errors in the past too, e.g. #880 says it broke all requests to pinterest.
The text was updated successfully, but these errors were encountered: