You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: reduce comments, align with repo conventions
- Remove @example block from forHostIframe JSDoc (only constructors use it)
- Reduce example JSDoc to single line matching existing style
- Merge redundant test case, remove describe-level comment
- Move isInitializationTimeoutError to private static on App class
- Use DEFAULT_REQUEST_TIMEOUT_MSEC instead of hardcoded 60000
- Streamline quickstart docs: remove sub-headings and anti-pattern block,
use [!CAUTION] callout matching existing doc style
Made-with: Cursor
Copy file name to clipboardExpand all lines: docs/quickstart.md
+4-26Lines changed: 4 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -480,12 +480,7 @@ You've built your first MCP App!
480
480
481
481
When building your own host (instead of using an existing MCP client), the order of operations matters. The host must start listening for messages **before** the View begins executing, otherwise the View's `ui/initialize` request will be lost.
482
482
483
-
### Correct Order
484
-
485
-
1.**Create and attach the iframe** to the document
486
-
2.**Create the transport** using `PostMessageTransport.forHostIframe(iframe)`
487
-
3.**Connect the bridge** with `await bridge.connect(transport)`
488
-
4.**Then** set `iframe.srcdoc` or `iframe.src` to load the View
483
+
`iframe.contentWindow` is available as soon as the iframe is in the DOM (it points to the initial `about:blank` document) — you do not need to wait for `onload` to create the transport.
//NOW load the content — ui/initialize will be received
499
+
//Set content AFTER connecting — view's ui/initialize will be received
508
500
iframe.srcdoc=htmlContent;
509
501
```
510
502
511
-
The `iframe.contentWindow` reference is available as soon as the iframe is in the DOM (it points to the initial `about:blank` document). You do **not** need to wait for `onload` to create the transport.
const transport =PostMessageTransport.forHostIframe(iframe);
519
-
awaitbridge.connect(transport); // Too late — message was already lost
520
-
```
521
-
522
-
If you see a timeout error like:
523
-
524
-
> `ui/initialize: no response within 60s — host may have loaded the View before connecting its transport`
525
-
526
-
This is the likely cause. Reorder your code to connect the transport first.
503
+
> [!CAUTION]
504
+
> Setting `srcdoc` or `src`**before** connecting the transport will cause the View's `ui/initialize` to be lost. If you see a timeout like `"no response within 60s"`, this is the likely cause.
0 commit comments