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
{{ message }}
Repository navigation
HTTP/2: TypeError: Cannot read properties of null (reading 'onResponseError') #5404
When we allowH2 on our canary prod deployment, the process is inevitably going to crash on 8.4.x.
I can't remember if I tested on 8.3, but previous 8.x releases did not crash.
Reproducible By
Not entirely sure, but we only get that crash when we toggle allowH2 explictly (disabled otherwise and doesn't crash).
We use undici.request and a pre-configured Agent.
Expected Behavior
No crashes when enabling HTTP/2.
Logs & Screenshots
Process crashing with:
/usr/src/app/node_modules/undici/lib/core/util.js:843
request.onResponseError(err)
^
TypeError: Cannot read properties of null (reading 'onResponseError')
at Object.errorRequest (/usr/src/app/node_modules/undici/lib/core/util.js:843:13)
at /usr/src/app/node_modules/undici/lib/dispatcher/client.js:398:14
at new Promise (<anonymous>)
at [destroy] (/usr/src/app/node_modules/undici/lib/dispatcher/client.js:394:12)
at Client.destroy (/usr/src/app/node_modules/undici/lib/dispatcher/dispatcher-base.js:145:19)
at /usr/src/app/node_modules/undici/lib/dispatcher/dispatcher-base.js:109:14
at new Promise (<anonymous>)
at Client.destroy (/usr/src/app/node_modules/undici/lib/dispatcher/dispatcher-base.js:108:14)
at /usr/src/app/node_modules/undici/lib/dispatcher/dispatcher-base.js:97:24
at runNextTicks (node:internal/process/task_queues:65:5)
Emitted 'error' event on Client instance at:
at Object.errorRequest (/usr/src/app/node_modules/undici/lib/core/util.js:846:12)
at /usr/src/app/node_modules/undici/lib/dispatcher/client.js:398:14
at new Promise (<anonymous>)
at [destroy] (/usr/src/app/node_modules/undici/lib/dispatcher/client.js:394:12)
at Client.destroy (/usr/src/app/node_modules/undici/lib/dispatcher/dispatcher-base.js:145:19)
at /usr/src/app/node_modules/undici/lib/dispatcher/dispatcher-base.js:109:14
at new Promise (<anonymous>)
at Client.destroy (/usr/src/app/node_modules/undici/lib/dispatcher/dispatcher-base.js:108:14)
at /usr/src/app/node_modules/undici/lib/dispatcher/dispatcher-base.js:97:24
at runNextTicks (node:internal/process/task_queues:65:5)
Node.js v26.3.0
Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that.
I wasn't quite sure what's the issue, but GPT-5.5 comes to the rescue. It seems to be possible whenever a connection gets closed but another stream is also waiting for response.
repro.mjs
import{createServer}from"node:http2";import{once}from"node:events";import{setTimeout}from"node:timers/promises";import{Agent}from"./index.js";// or from "undici";constserver=createServer();server.on("stream",async(stream,headers)=>{if(headers[":path"]==="/slow"){awaitsetTimeout(50);stream.respond({":status": 200});stream.end("slow");}else{stream.close();}});server.listen(0);awaitonce(server,"listening");constorigin=`http://localhost:${server.address().port}`;constdispatcher=newAgent({connections: 1,useH2c: true,});constslow=dispatcher.request({ origin,path: "/slow",method: "GET"}).then(async(res)=>res.body.text());constbad=dispatcher.request({ origin,path: "/bad",method: "GET"}).catch((err)=>{console.log("bad request failed as expected:",err.name,err.message);});awaitbad;console.log("slow result:",awaitslow);awaitdispatcher.close();const{ promise, resolve }=Promise.withResolvers();server.close(resolve);awaitpromise;
Activity
mcollina commentedon Jun 9, 2026
Thanks for reporting!
Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that.
slagiewka commentedon Jun 9, 2026
I wasn't quite sure what's the issue, but GPT-5.5 comes to the rescue. It seems to be possible whenever a connection gets closed but another stream is also waiting for response.
repro.mjs
Stack trace looks identical.
fix(h2): do not rewind kPendingIdx past in-flight requests (nodejs#5408)
fix(h2): retire the request that completed, not the head of the queue (…