Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
fix(diagnostics): handle late request errors until socket close (#35496)
OrcaWinc2cc986a8dcd
diff --git a/src/main/observability/diagnostic-upload-http.test.ts b/src/main/observability/diagnostic-upload-http.test.tsindex d7b73ba63ad..e12c937e9cf 100644--- a/src/main/observability/diagnostic-upload-http.test.ts+++ b/src/main/observability/diagnostic-upload-http.test.ts@@ -35,6 +35,7 @@ describe('diagnostic upload HTTP', () => {response.emit('data', Buffer.from('private backend details: not JSON'))response.emit('end')await expect(result).rejects.toThrow(/^HTTP 503$/)+ request.emit('close')expect(response.listenerCount('data')).toBe(0)expect(request.listenerCount('error')).toBe(0)})@@ -52,6 +53,7 @@ describe('diagnostic upload HTTP', () => {response.emit('end')await expect(result).resolves.toEqual({ accepted: true })+ request.emit('close')expect(request.listenerCount('error')).toBe(0)expect(request.listenerCount('timeout')).toBe(0)expect(response.listenerCount('data')).toBe(0)@@ -71,6 +73,7 @@ describe('diagnostic upload HTTP', () => {response.emit('data', Buffer.alloc(MAX_RESPONSE_BYTES + 1))await expect(result).rejects.toThrow('diagnostic response exceeded size limit')+ request.emit('close')expect(request.destroy).toHaveBeenCalledTimes(1)expect(response.destroy).toHaveBeenCalledTimes(1)expect(request.listenerCount('error')).toBe(0)@@ -79,4 +82,17 @@ describe('diagnostic upload HTTP', () => {expect(response.listenerCount('end')).toBe(0)expect(response.listenerCount('error')).toBe(0)})++ it('handles the asynchronous socket error after a request timeout until close', async () => {+ const request = new FakeRequest()+ httpRequestMock.mockReturnValueOnce(request)+ const result = postJsonForJson('http://diagnostics.example/upload', {}, 1000)+ request.emit('timeout')++ await expect(result).rejects.toThrow('diagnostic network request timed out')+ expect(request.destroy).toHaveBeenCalledOnce()+ expect(() => request.emit('error', new Error('socket hang up'))).not.toThrow()+ request.emit('close')+ expect(request.eventNames()).toEqual([])+ })})diff --git a/src/main/observability/diagnostic-upload-http.ts b/src/main/observability/diagnostic-upload-http.tsindex 357ae1aa4da..a555e4d1812 100644--- a/src/main/observability/diagnostic-upload-http.ts+++ b/src/main/observability/diagnostic-upload-http.ts@@ -43,7 +43,6 @@ function postRaw(const chunks: Buffer[] = []let responseBytes = 0function cleanupListeners(): void {- req?.off('error', onRequestError)req?.off('timeout', onRequestTimeout)res?.off('data', onResponseData)res?.off('end', onResponseEnd)@@ -143,6 +142,7 @@ function postRaw(})req.on('error', onRequestError)+ req.once('close', () => req?.off('error', onRequestError))req.on('timeout', onRequestTimeout)req.write(body)req.end()