Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception parsing HTTP/2 Headers when multiple set-cookie is sent #3046

Closed
st3ffgv4 opened this issue Apr 3, 2024 · 1 comment · Fixed by #3047
Closed

Exception parsing HTTP/2 Headers when multiple set-cookie is sent #3046

st3ffgv4 opened this issue Apr 3, 2024 · 1 comment · Fixed by #3047
Labels
bug Something isn't working

Comments

@st3ffgv4
Copy link
Contributor

st3ffgv4 commented Apr 3, 2024

Bug Description

By making requests to websites that return multiple set-cookie header with HTTP/2 enabled, an exception is triggered while processing the headers

Reproducible By

https://replit.com/@gava97/H2-headers

Expected Behavior

No exception thrown, headers parsed correctly

Logs & Screenshots

(node:1160) [UNDICI-H2] Warning: H2 support is experimental, expect them to change at any time.
(Use node --trace-warnings ... to show where the warning was created)
TypeError: fetch failed
at fetch (/home/runner/H2-headers/node_modules/undici/index.js:109:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async file:///home/runner/H2-headers/index.js:8:13 {
[cause]: TypeError: Cannot read properties of undefined (reading 'toString')
at Object.onHeaders (/home/runner/H2-headers/node_modules/undici/lib/web/fetch/index.js:2135:97)
at Request.onHeaders (/home/runner/H2-headers/node_modules/undici/lib/core/request.js:243:29)
at ClientHttp2Stream. (/home/runner/H2-headers/node_modules/undici/lib/dispatcher/client-h2.js:420:17)
at Object.onceWrapper (node:events:633:26)
at ClientHttp2Stream.emit (node:events:518:28)
at emit (node:internal/http2/core:331:3)
at process.processTicksAndRejections (node:internal/process/task_queues:85:22)

image

Environment

Node v20.11.1
undici 6.11.1

Additional context

This bug is present onliy in undici >= 6.11

@st3ffgv4 st3ffgv4 added the bug Something isn't working label Apr 3, 2024
@metcoder95
Copy link
Member

Yes, we changed the way we parse the response headers; it seems the root cause goes to the way we parse the setCookie, as with node:http2, multiple set-cookie headers are consolidated into an array of multiple values, we need to change that so fetch can parse it accordingly to the spec.

Working on a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants