Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(desktop): ignore expected Pi shutdown errors (#93318)

Jonathan Mieloo5f1164ad9672
diff --git a/products/desktop/packages/core/src/pi-runtime/piExtensionController.test.ts b/products/desktop/packages/core/src/pi-runtime/piExtensionController.test.ts
index fc95b9fc9834..7776f98b131d 100644
--- a/products/desktop/packages/core/src/pi-runtime/piExtensionController.test.ts
+++ b/products/desktop/packages/core/src/pi-runtime/piExtensionController.test.ts
@@ -191,6 +191,20 @@ describe("PiExtensionController", () => {
expect(controller.store.getState().tasks["task-1"]).toBeUndefined();
});
+ it("ignores a missing Pi session when the extension subscription ends", async () => {
+ const handlers: ExtensionSubscriptionHandlers[] = [];
+ const session = createSession(handlers);
+ const controller = createController(session);
+ await controller.connect("task-1");
+
+ handlers[0].error(new Error("Pi session not found for task task-1"));
+
+ expect(controller.store.getState().tasks["task-1"].notifications).toEqual(
+ [],
+ );
+ controller.disconnect("task-1");
+ });
+
it("preserves pending state on reconnect and ignores stale callbacks", async () => {
vi.useFakeTimers();
try {
diff --git a/products/desktop/packages/core/src/pi-runtime/piExtensionController.ts b/products/desktop/packages/core/src/pi-runtime/piExtensionController.ts
index 177468b0626e..ae7ba396905b 100644
--- a/products/desktop/packages/core/src/pi-runtime/piExtensionController.ts
+++ b/products/desktop/packages/core/src/pi-runtime/piExtensionController.ts
@@ -258,7 +258,10 @@ export class PiExtensionController {
return;
}
- if (error !== undefined) {
+ if (
+ error !== undefined &&
+ !String(error).includes("Pi session not found for task")
+ ) {
this.dispatch(taskId, {
type: "notification",
notification: {