Skip to content

fix: remove false-positive cancel warning in AIChatAgent#1290

Merged
threepointone merged 1 commit intomainfrom
remove-missed-abort-signal-warning
Apr 11, 2026
Merged

fix: remove false-positive cancel warning in AIChatAgent#1290
threepointone merged 1 commit intomainfrom
remove-missed-abort-signal-warning

Conversation

@threepointone
Copy link
Copy Markdown
Contributor

@threepointone threepointone commented Apr 11, 2026

Summary

  • Removes the console.warn about "Stream was still active when cancel was received" from both _streamSSEReply and _sendPlaintextReply
  • The warning fired on every cancellation — even when the user correctly passed abortSignal to streamText() — because the internal safety-net reader.cancel() always races ahead of the stream's natural termination
  • Fixes [WARNING] [AIChatAgent] Stream was still active when cancel was received #1288

Context

When the abort signal fires, our listener immediately calls reader.cancel(), which resolves reader.read() with { done: true }. This is indistinguishable from the stream ending naturally because the user wired abortSignal to streamText(). Both produce the same state, so the warning was a false positive in the correctly-wired case.

The safety-net reader.cancel() mechanism (which prevents broadcasting further chunks) is preserved — only the misleading warning is removed.

Test plan

  • All 5 existing cancel tests pass (cancel-request.test.ts)
  • All 5 abort transport tests pass (ws-transport-abort.test.ts)
  • No tests reference the warning text

Made with Cursor


Open with Devin

Eliminate duplicate console.warn messages in AIChatAgent when a stream is aborted. The code still marks streams as completed and broadcasts the final chat/text events, but no longer logs the noisy warning about passing options.abortSignal. This reduces log clutter during expected abort flows in packages/ai-chat/src/index.ts.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 11, 2026

🦋 Changeset detected

Latest commit: aec62af

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cloudflare/ai-chat Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 11, 2026

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@1290

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@1290

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@1290

hono-agents

npm i https://pkg.pr.new/hono-agents@1290

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@1290

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@1290

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@1290

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@1290

commit: aec62af

@threepointone threepointone merged commit 6429189 into main Apr 11, 2026
2 checks passed
@threepointone threepointone deleted the remove-missed-abort-signal-warning branch April 11, 2026 16:23
@github-actions github-actions bot mentioned this pull request Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[WARNING] [AIChatAgent] Stream was still active when cancel was received

1 participant