feat: add queueMessages option to waitForReady#46
Merged
avigoldman merged 6 commits intomainfrom Mar 30, 2026
Merged
Conversation
When waitForReady({ queueMessages: true }) is called, broadcast()
queues messages instead of sending them. Once the handshake completes
(or times out), the queue is flushed automatically.
This lets consumers call waitForReady() once and then broadcast()
freely without worrying about message loss during iframe
initialization — no external queuing logic needed.
karngyan
approved these changes
Mar 30, 2026
- On timeout, queued messages are NOT flushed (iframe isn't ready, they'd be lost anyway). Consumer catches the rejection and decides. - Add public clearQueue() for teardown scenarios (e.g. unmounting during the handshake window).
🦋 Changeset detectedLatest commit: 3fd0c4d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Separate onReady (flush) and onTimeout (discard) into distinct paths instead of a shared cleanup(boolean). Inline the flush logic so the flow is readable top-to-bottom.
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.
What
Adds a
queueMessagesoption towaitForReady(). When enabled,broadcast()calls made while waiting for the handshake are automatically queued and flushed once the other side signals readiness.Why
Without this, consumers need to build their own message queuing logic to avoid losing messages during iframe initialization. With
queueMessages: true, the consumer just callswaitForReady()and thenbroadcast()freely — framecast handles the rest.API
Testing
4 new tests covering: queue + flush on ready, flush on timeout (best-effort), no queuing after ready, opt-out with
queueMessages: false.Follows up on #44 (signalReady/waitForReady). Related: CON-6607