Preserve accepted plugin writes during idle preparation

Keep worker-to-host writes admitted until the worker confirms its accepted handlers have drained. Release only the matching preparation and log session callback failures.

Verified with 13 idle RPC tests, adjacent worker tests, and server typecheck.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Devin FoleyandPaperclip committed 2026-10-08 12:12:28 -07:00
1 parent 6a770ce096
commit 2cf0d1af00
5 files changed
+76 -10

No files matched your search

+6 -1
View File
@@ -2322,7 +2322,12 @@ export function startWorkerRpcHost(options: WorkerRpcHostOptions): WorkerRpcHost
} else if (notif.method === "agents.sessions.event" && notif.params) {
const event = notif.params as AgentSessionEvent;
const cb = sessionEventCallbacks.get(event.sessionId);
if (cb) void runNotification(() => cb(event)).catch(() => undefined);
if (cb) void runNotification(() => cb(event)).catch((err) => {
notifyHost("log", {
level: "error",
message: `Failed to handle session event notification: ${err instanceof Error ? err.message : String(err)}`,
});
});
} else if (notif.method === "onEvent" && notif.params) {
// Plugin event bus notifications — dispatch to registered event handlers
Promise.resolve(runNotification(() => handleOnEvent(notif.params as OnEventParams))).catch((err) => {