Skip to content

HTTP/2: TypeError: Cannot read properties of null (reading 'onResponseError') #5404

Description

@slagiewka

Bug Description

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

Environment

Undici v8.4.1
Node v26.3.0 (distroless container)

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions