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(agent-proxy): address review comments from #67555 (#67576)

Charles Vien6e0697a67ec4
diff --git a/services/agent-proxy/src/hono/ingest-handler.ts b/services/agent-proxy/src/hono/ingest-handler.ts
index 0838c40e0840..65385ef46fc8 100644
--- a/services/agent-proxy/src/hono/ingest-handler.ts
+++ b/services/agent-proxy/src/hono/ingest-handler.ts
@@ -411,6 +411,7 @@ function isClientAbortError(err: unknown): boolean {
return true
}
const code = (err as NodeJS.ErrnoException).code
+ // 'aborted' is undici's body-read abort message; it carries no error code, unlike the others.
return code === 'ECONNRESET' || code === 'ERR_STREAM_PREMATURE_CLOSE' || err.message === 'aborted'
}
diff --git a/services/agent-proxy/src/lib/types.ts b/services/agent-proxy/src/lib/types.ts
index 59707432b35c..95252aef9cb6 100644
--- a/services/agent-proxy/src/lib/types.ts
+++ b/services/agent-proxy/src/lib/types.ts
@@ -63,11 +63,11 @@ export class EventIngestPayloadTooLarge extends Error {
}
export class ClientDisconnected extends Error {
- constructor(
- public accepted: number = 0,
- public duplicate: number = 0,
- public lastAcceptedSeq: number = 0
- ) {
+ accepted = 0
+ duplicate = 0
+ lastAcceptedSeq = 0
+
+ constructor() {
super('Client disconnected during event ingest')
this.name = 'ClientDisconnected'
}
diff --git a/services/agent-proxy/tests/hono/ingest-handler.test.ts b/services/agent-proxy/tests/hono/ingest-handler.test.ts
index 34d1ab3abb82..c252b39b2f94 100644
--- a/services/agent-proxy/tests/hono/ingest-handler.test.ts
+++ b/services/agent-proxy/tests/hono/ingest-handler.test.ts
@@ -899,6 +899,7 @@ describe('ingest-handler', () => {
},
])('treats a mid-body $variant as a client disconnect, not a server error', async ({ makeError }) => {
const infoSpy = vi.spyOn(logger, 'info')
+ const errorSpy = vi.spyOn(logger, 'error')
const config = makeConfig()
const enc = new TextEncoder()
const line = enc.encode(JSON.stringify({ seq: 1, event: { type: 'before-drop' } }) + '\n')
@@ -925,6 +926,7 @@ describe('ingest-handler', () => {
const log = infoSpy.mock.calls.find((c) => c[0] === 'ingest:client_disconnect')?.[1] as Record<string, unknown>
expect(log).toMatchObject({ run: RUN_ID, accepted: 1, lastSeq: 1 })
+ expect(errorSpy).not.toHaveBeenCalledWith('http.unhandled_error', expect.anything())
})
// -----------------------------------------------------------------------