Skip to content

Pi crashes on uncaught ERR_HTTP2_INVALID_SESSION from undici HTTP/2 transport #4682

@coskunarif

Description

@coskunarif

Summary

Pi interactive session can crash with an uncaught ERR_HTTP2_INVALID_SESSION from undici HTTP/2 transport during a long-running Objective Loop session.

This appears to be a provider/transport-level crash because the stack trace is entirely inside Node/undici/Pi package dependencies, not the Objective Loop extension.

Environment

  • Pi package: @earendil-works/pi-coding-agent 0.75.1
  • Pi CLI: pi --version => 0.75.1
  • Node: v22.16.0
  • OS: Ubuntu 24.04 under WSL
  • Model/provider in TUI: openai-codex / gpt-5.5 low
  • Invocation path: pi-objective-loop wrapper loading Objective Loop extension, but stack has no extension frames

What happened

While pi-objective-loop was running an interactive session, after several approved iterations, Pi exited with an uncaught exception:

pi exiting due to uncaughtException:
Error [ERR_HTTP2_INVALID_SESSION]: The session has been destroyed
    at ClientHttp2Session.request (node:internal/http2/core:1766:13)
    at requestStream (/home/ubuntuadmin/.nvm/versions/node/v22.16.0/lib/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/client-h2.js:737:22)
    at writeH2 (/home/ubuntuadmin/.nvm/versions/node/v22.16.0/lib/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/client-h2.js:925:12)
    at Object.write (/home/ubuntuadmin/.nvm/versions/node/v22.16.0/lib/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/client-h2.js:210:14)
    at _resume (/home/ubuntuadmin/.nvm/versions/node/v22.16.0/lib/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/client.js:658:50)
    at resume (/home/ubuntuadmin/.nvm/versions/node/v22.16.0/lib/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/client.js:576:3)
    at /home/ubuntuadmin/.nvm/versions/node/v22.16.0/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'
}

The wrapper then reported:

Objective Loop run ended: 20260518T074903Z-118215 (exit 1)
Analyze: objective-improve-last --run-id 20260518T074903Z-118215

Expected behavior

A destroyed HTTP/2 session should not crash the Pi process as an uncaught exception. Ideally Pi/provider transport should either:

  • retry once with a fresh HTTP/2 session when safe, or
  • surface a recoverable provider error to the agent/session, or
  • gracefully end the current request with a useful error message and preserve session state.

Actual behavior

The whole Pi process exited from an uncaught exception.

Notes

Because this happened inside a long-running autonomous Objective Loop session, the impact is high: a transient provider HTTP/2 session failure terminates the run. Objective Loop can potentially add wrapper-level recovery, but the root crash looks like Pi/undici/provider transport should guard this error.

Please let me know if there is a debug flag or provider transport setting that would help capture more detail if it recurs.

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