Skip to content

0.75.1 crashes with ERR_HTTP2_INVALID_SESSION from undici client-h2 #4681

@fairusage

Description

@fairusage

Summary

Pi 0.75.1 can exit from an uncaught ERR_HTTP2_INVALID_SESSION during provider requests. I hit it repeatedly while running subagents, but the stack is in Pi's provider HTTP path, not in the subagent extension itself.

Downgrading to 0.74.0 stopped new sessions from hitting this path after I killed/restarted old Pi processes.

Environment

  • Pi: 0.75.1
  • Node: 22.21.1
  • Platform: macOS
  • Provider/model in the crashing sessions: openai-codex / gpt-5.5
  • Pi 0.75.1 dependency path in stack: @earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/client-h2.js

Crash

pi exiting due to uncaughtException:
Error [ERR_HTTP2_INVALID_SESSION]: The session has been destroyed
    at ClientHttp2Session.request (node:internal/http2/core:1808:13)
    at requestStream (/Users/ignasgabijunas/.local/share/mise/installs/node/22.21.1/lib/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/client-h2.js:737:22)
    at writeH2 (/Users/ignasgabijunas/.local/share/mise/installs/node/22.21.1/lib/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/client-h2.js:925:12)
    at Object.write (/Users/ignasgabijunas/.local/share/mise/installs/node/22.21.1/lib/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/client-h2.js:210:14)
    at _resume (/Users/ignasgabijunas/.local/share/mise/installs/node/22.21.1/lib/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/client.js:658:50)
    at resume (/Users/ignasgabijunas/.local/share/mise/installs/node/22.21.1/lib/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/client.js:576:3)
    at /Users/ignasgabijunas/.local/share/mise/installs/node/22.21.1/lib/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/client.js:350:28
    at node:internal/process/task_queues:151:7
    at AsyncResource.runInAsyncScope (node:async_hooks:214:14)
    at AsyncResource.runMicrotask (node:internal/process/task_queues:148:8) {
  code: 'ERR_HTTP2_INVALID_SESSION'
}

What I checked

  • 0.75.1 uses undici@8.3.0 and calls installUndiciGlobals() in dist/cli.js.
  • With undici@8.3.0, undici.fetch() negotiates HTTP/2 (h2) for chatgpt.com / OpenAI endpoints.
  • The crash stack line client-h2.js:737 matches undici@8.3.0's session.request(...) call.
  • After installing @earendil-works/pi-coding-agent@0.74.0, the installed dependency was undici@7.25.0, and new Pi sessions no longer matched that stack. Old already-running Pi processes still crashed until restarted.

Expected

Provider transport errors should be caught and surfaced as a retryable provider error. Pi should not exit from an uncaught exception.

Workaround

npm install -g @earendil-works/pi-coding-agent@0.74.0
pkill -x pi

Then start Pi again and confirm:

pi --version
# 0.74.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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