Skip to content

fix: remove redundant unawaited updateProps calls in MCP handlers#1022

Merged
threepointone merged 1 commit intomainfrom
fix/remove-unawaited-updateProps
Feb 28, 2026
Merged

fix: remove redundant unawaited updateProps calls in MCP handlers#1022
threepointone merged 1 commit intomainfrom
fix/remove-unawaited-updateProps

Conversation

@threepointone
Copy link
Contributor

Fixes #1007

Problem

Sporadic "Failed to pop isolated storage stack frame" errors in test environments when using McpAgent. The vitest-pool-workers test runner detects unawaited Durable Object storage operations during teardown.

Root Cause

Three agent.updateProps(ctx.props) calls in packages/agents/src/mcp/utils.ts were fire-and-forget RPC calls (not awaited). Each call dispatches ctx.storage.put("props", ...) inside the Durable Object, but the returned Promise was never awaited in the outer Worker handler.

These calls were also redundantgetAgentByName() already passes props via the x-partykit-props header, which triggers onStart(props)await updateProps(props) inside the DO. The unawaited calls simply repeated the same storage write with the same data.

Changes

  • packages/agents/src/mcp/utils.ts: Removed 3 redundant unawaited updateProps calls (Streamable HTTP POST, Streamable HTTP GET, Legacy SSE GET)
  • packages/agents/src/index.ts: Removed RPC experimental warning from addMcpServer
  • packages/agents/src/tests/mcp/mcp-protocol.test.ts: Added props tests for Streamable HTTP GET and RPC transport paths

Verification

  • npm run check — all 45 projects typecheck ✅
  • npm run test — 267 tests pass ✅
  • MCP-specific tests — 346 tests pass (18 files) ✅

Remove unawaited, redundant agent.updateProps calls from MCP transport handlers to fix sporadic "Failed to pop isolated storage stack frame" errors in tests (props are already delivered via getAgentByName → onStart). Also remove the one-time RPC experimental console warning in addMcpServer. Add tests to verify props are passed via standalone SSE and RPC. Include a changeset entry documenting the patch.
@changeset-bot
Copy link

changeset-bot bot commented Feb 28, 2026

🦋 Changeset detected

Latest commit: d9580ad

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

This PR includes changesets to release 1 package
Name Type
agents 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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 28, 2026

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/agents@1022
npm i https://pkg.pr.new/cloudflare/agents/@cloudflare/ai-chat@1022
npm i https://pkg.pr.new/cloudflare/agents/@cloudflare/codemode@1022
npm i https://pkg.pr.new/cloudflare/agents/hono-agents@1022

commit: d9580ad

@threepointone threepointone merged commit c2bfd3c into main Feb 28, 2026
4 checks passed
@threepointone threepointone deleted the fix/remove-unawaited-updateProps branch February 28, 2026 09:05
@github-actions github-actions bot mentioned this pull request Feb 28, 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.

Occasional "Failed to pop isolated storage stack frame" error in test environment

1 participant