I love fetch, except for the way that it combines headers. If more than one of the same header is set (such as multiple set-cookie headers), it combines them all into a single comma-separated string. I know this is allowed in the HTTP spec, and it's probably even a sensible default. But the fetch spec doesn't allow any access to the raw headers, so there's no straightforward way to get the original uncombined headers back. Set-Cookie headers, in particular, often contain commas in their expiration dates, so just splitting around `, ` will lead to problems.<p>I took a look through the source of this new fetch API, and it seems to have inherited that wart:
<a href="https://github.com/nodejs/undici/blob/2dd3437e20c5a3cc466226c544f048351baffc78/lib/fetch/headers.js#L103" rel="nofollow">https://github.com/nodejs/undici/blob/2dd3437e20c5a3cc466226...</a><p>I've argued with the authors of the fetch spec about this before, and ultimately settled on using <a href="https://www.npmjs.com/package/set-cookie-parser#user-content-splitcookiesstringcombinedsetcookieheader" rel="nofollow">https://www.npmjs.com/package/set-cookie-parser#user-content...</a> to work around this flaw. (For clarity, I published the package, but chrusart wrote that method - <a href="https://github.com/nfriedly/set-cookie-parser/pull/19" rel="nofollow">https://github.com/nfriedly/set-cookie-parser/pull/19</a>)