ag-ui-protocol / ag-ui-protocol/ag-ui

[Bug]: Unhandled rejection in runHttpRequest()

未關閉
#2,510 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
bug
主要語言
Python
星號
15.9k
分支
1.4k
平均合併
1 天 17 小時
30 天內合併 PR
163

描述

### Pre-flight Checklist

- [x] I have searched [existing issues](https://github.com/ag-ui-protocol/ag-ui/issues) and this hasn't been reported yet.
- [x] I am using the **latest** version AG-UI.

### Describe the Bug

I have an agentcore langraph agent running on localhost. I've created a `CopilotRuntime` with `InMemoryAgentRunner`. This runner will crash with unhandled rejection if I terminate my agentcore process midstream.

It seems that the issue is caused by https://github.com/ag-ui-protocol/ag-ui/blob/main/sdks/typescript/packages/client/src/run/http-request.ts

```ts
return new Observable((subscriber) => {
// Emit headers event first
subscriber.next(headersEvent);

(async () => {
...
}
})();

return () => {
reader.cancel().catch((error) => {
if ((error as DOMException)?.name === "AbortError") {
return;
}

throw error;
});
};
});
```

the issue is reader.cancel is an async function. it throws error after socket was closed and rethrows it in the catch block, resulting in unhandled rejection.

### Steps to Reproduce

Create copilotkit runtime per https://docs.copilotkit.ai/langgraph-python/backend/copilot-runtime
Kill agent while a query is running

### Expected Behavior

no unhandled rejections occur

### Environment

```text
"@ag-ui/client": "0.0.57",
"@copilotkit/runtime": "1.68.1",
"@hono/node-server": "^2.1.1",
"hono": "^4.13.2",
"rxjs": "^7.8.2"
```

### Screenshots

_No response_

### Logs & Errors

```shell

```

### Additional Context

_No response_

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。