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

[Bug]: Unhandled rejection in runHttpRequest()

Offen
#2,510 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug
Vorherrschende Sprache
Python
Sterne
15.9k
Forks
1.4k
Ø Merge
1 T. 17 Std.
Gemergte PRs (30 T.)
163

Beschreibung

### 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_

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.