fix(canvas): buffer runtime messages posted before the port connects - #78243
Merged
Conversation
|
😎 Merged successfully - details. |
jakesciotto
marked this pull request as ready for review
August 5, 2026 13:54
Contributor
Prompt To Fix All With AI### Issue 1
products/canvas/packages/canvas_builder/build.mjs:30
**Expired requests still execute**
When the MessagePort connects more than 30 seconds after a pre-connect `ph.capture` call, the timeout removes only the pending promise entry while leaving its payload queued, so the subsequent flush records the event after the caller has already received a timeout; expired queries and insight requests are likewise executed with their responses ignored.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "fix(canvas): buffer runtime messages pos..." | Re-trigger Greptile |
jakesciotto
force-pushed
the
fix/canvas-runtime-port-buffer
branch
from
August 7, 2026 02:26
e5ffb2e to
6db7118
Compare
Contributor
Author
|
Addressed the Greptile finding in 6db7118: a request whose timeout fires while still queued is now removed from the queue, so a late connect no longer executes expired captures or queries. The harness test covers this case (it fails with the splice removed). Also rebased onto master's themed runtime to clear the conflict. |
jakesciotto
force-pushed
the
fix/canvas-runtime-port-buffer
branch
from
August 7, 2026 02:34
6db7118 to
4e13464
Compare
jakesciotto
enabled auto-merge (squash)
August 7, 2026 04:56
The host delivers the MessagePort only after the artifact iframe's load event, which fires after the app's module scripts ran. A ph.query issued during mount was silently dropped by port?.postMessage and rejected 30s later with "Canvas request timed out". The runtime now queues pre-connect messages (bounded) and flushes them when the port arrives. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A pre-connect ph.* request whose 30s timeout already rejected stayed in the queue, so a late-connecting host still executed it after the caller gave up. The timeout now removes the queued payload alongside the pending promise. Generated-By: PostHog Code Task-Id: 63fc8373-9e47-48f5-b6ba-23a48d562593
canvas-runtime.js now bundles the selection and highlight runtimes after the data bridge, and those touch document.addEventListener, createElement, head.appendChild, body, and MutationObserver at load. The flush-test harness only stubbed readyState, so the bundled file threw before any assertion ran. Generated-By: PostHog Code Task-Id: 63fc8373-9e47-48f5-b6ba-23a48d562593
jakesciotto
force-pushed
the
fix/canvas-runtime-port-buffer
branch
from
August 12, 2026 19:05
781089f to
21a2041
Compare
k11kirky
approved these changes
Aug 14, 2026
Contributor
|
/trunk merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
port?.postMessage(...)drops anything posted before that.Changes
How did you test this code?
test_runtime_flushes_data_requests_queued_before_the_port_connectsruns the built runtime under node with a fake port and fake timers.Automatic notifications
Docs update
None.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Created with PostHog Code