nodejs/undici

Invalid HTTP2 headers should be recoverable

已關閉

#4,356 建立於 2025年7月22日

 (6 則留言) (0 個反應) (0 位負責人)JavaScript (444 個分叉)batch import
buggood first issue

倉庫指標

星標
 (5,319 顆星)
PR 合併指標
 (平均合併 2天 10小時) (30 天內合併 82 個 PR)

描述

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 https://github.com/nodejs/undici/discussions/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

貢獻者指南