Skip to content

Comments

fix: deduplicate preview deploys and normalize malformed WS envelopes#334

Closed
rarestg wants to merge 6 commits intocloudflare:mainfrom
rarestg:fix/frontend-preview-dedupe-and-ws-normalization
Closed

fix: deduplicate preview deploys and normalize malformed WS envelopes#334
rarestg wants to merge 6 commits intocloudflare:mainfrom
rarestg:fix/frontend-preview-dedupe-and-ws-normalization

Conversation

@rarestg
Copy link

@rarestg rarestg commented Feb 16, 2026

Summary

  • Gate sendWebSocketMessage(websocket, 'preview') behind an in-flight guard (previewDeployInFlight) so reconnects and cf_agent_state transitions do not trigger duplicate preview deploy requests. The guard resets on deployment_completed or deployment_failed.
  • Normalize malformed websocket envelopes where message.type contains a stringified JSON payload (e.g. { type: '{"state":...,"type":"cf_agent_state"}' }) before dispatching to the switch handler.

Addresses P1 items from the sandbox RCA: preview deploy deduplication and websocket envelope normalization.

Test plan

  • Reconnect to an existing chat session with generated files and verify only one preview WS message is sent (check network tab)
  • Trigger a cf_agent_state update while preview is already deploying and verify no duplicate deploy
  • Verify malformed type field messages (stringified JSON) are correctly normalized and handled as cf_agent_state

Generated with Claude Code

rarestg and others added 6 commits February 15, 2026 19:19
Applied consistent formatting across all files using prettier with:
- singleQuote: true
- printWidth: 120
- 2-space indentation (spaces, not tabs)

Added .prettierignore, format/format:check scripts, and updated
.editorconfig to match.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The previous formatting commit only applied quote and line-length
changes but did not convert indentation from tabs to spaces per
the .editorconfig and prettier config. This completes that work.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…velopes

Gate preview deploy requests behind an in-flight guard so reconnects and
state transitions do not trigger duplicate deploys. Normalize websocket
messages where `type` contains stringified JSON before switch dispatch.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rarestg
Copy link
Author

rarestg commented Feb 16, 2026

Opened against upstream by mistake. Recreating on fork.

@rarestg rarestg closed this Feb 16, 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.

1 participant