Skip to content

Invalid HTTP2 headers should be recoverable #4356

@dhalbrook

Description

@dhalbrook

Bug Description

If an invalid HTTP2 header is sent by the server, the client should be able to recover by retrying the operation. Right now it results in an uncaughtException. See #4341 for more details.

Reproducible By

To reproduce, a mock reply will need to be constructed where an HTTP2 connection to a server gets a response with an HTTP1 header like "http2-settings".

Ideally a runtime error is thrown, which can be caught in a block where Undici can be directed to retry the operation with a new connection.

Logs & Screenshots

Here is an example stack trace from when this occurs:

{err":{"type":"TypeError","message":"HTTP/1 Connection specific headers are forbidden: \"http2-settings\"","stack":"TypeError: HTTP/1 Connection specific headers are forbidden: \"http2-settings\"\n    
at mapToHeaders (node:internal/http2/util:651:13)\n    
at ClientHttp2Session.request (node:internal/http2/core:1813:25)\n    
at writeH2 (/.../node_modules/undici/lib/dispatcher/client-h2.js:469:22)\n    
at Object.write (/.../node_modules/undici/lib/dispatcher/client-h2.js:119:14)\n    
at _resume (/.../node_modules/undici/lib/dispatcher/client.js:601:50)\n    
at resume (/.../node_modules/undici/lib/dispatcher/client.js:303:28\n    
at node:internal/process/task_queues:140:7\n    
at AsyncResource.runInAsyncScope (node:async_hooks:206:9)\n    
at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)","code":"ERR_HTTP2_INVALID_CONNECTION_HEADERS"}

Environment

This was encountered using Node.js 22 on RHEL9.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions