Skip to content

[APPS-2958] Add: let the parent page keep a Live Preview backend call waiting - #609

Draft
tyffical wants to merge 1 commit into
tiffany.trinh/apps-2958-debug-bundle-call-inputsfrom
tiffany.trinh/apps-2958-frame-keepalive
Draft

tyffical wants to merge 1 commit into
tiffany.trinh/apps-2958-debug-bundle-call-inputsfrom
tiffany.trinh/apps-2958-frame-keepalive

Conversation

@tyffical

@tyffical tyffical commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Architecture

sequenceDiagram
    participant F as Frame (app)
    participant P as Parent page
    F->>P: app-builder:run-query, requestId
    Note over F: 2-minute wait and 60-minute cap start
    P->>F: app-builder:run-query:keepalive, same requestId
    Note over F: 2-minute wait restarts, cap unchanged
    P->>F: app-builder:run-query:response, same requestId
    Note over F: call settles, timers cleared
Loading
  • A keepalive counts only from the recipient a response would be accepted from, and only for the pending requestId.
  • POSTMESSAGE_MAX_WAIT_MS (60 minutes) is a safety net for a parent that never answers, not a deadline for the user. Both limits are wall-clock deadlines, so time the machine spends asleep counts toward them.

Changes

7 changes across protocol.ts, the postMessage transport, the dev client, test helpers and the README
What changed File
Add the app-builder:run-query:keepalive message type packages/plugins/apps/src/backend/protocol.ts
Re-arm a pending call's wall-clock timeout on a keepalive from its recipient, capped by POSTMESSAGE_MAX_WAIT_MS packages/plugins/apps/src/backend/client/transports/post-message-transport/post-message-transport.ts
Add the IframeQueryKeepAlive type packages/plugins/apps/src/backend/client/transports/post-message-transport/types.ts
Learn the parent's origin from a keepalive, as from a pong or response packages/plugins/apps/src/backend/client/dev-client/dev-client.ts
Add keepAlive() to the shared fake window packages/tests/src/_jest/helpers/fakeWindow.ts
Cover re-arm, timeout after the last keepalive, '*' posts, wrong source, wrong origin, unknown id, after reply, sleep, the cap and origin learning post-message-transport.test.ts, dev-client.test.ts
Document the framed call protocol and the keepalive packages/plugins/apps/README.md

QA Instructions

yarn build:all
# Expected: exit 0 ✅ VERIFIED

yarn test:unit packages/plugins/apps/src/backend/client/transports/post-message-transport/post-message-transport.test.ts
# Expected: Tests: 42 passed, 42 total ✅ VERIFIED

TMPDIR=<a dir under /private/tmp> yarn test:unit packages/plugins/apps/src --testPathIgnorePatterns network-guard
# Expected: Test Suites: 44 passed; Tests: 1027 passed ✅ VERIFIED (macOS needs a TMPDIR outside /var; CI on Linux doesn't)

yarn test:unit packages/plugins/apps/src/vite/network-guard.test.ts
# Expected: Tests: 129 passed, 129 total ✅ VERIFIED (run without TMPDIR set)

yarn lint && yarn typecheck:all && yarn cli integrity
# Expected: all exit 0, integrity leaves no extra changes ✅ VERIFIED
Fail-before
yarn test:unit packages/plugins/apps/src/backend/client/transports/post-message-transport/post-message-transport.test.ts packages/plugins/apps/src/backend/client/dev-client/dev-client.test.ts -t keepalive
# Expected on this head: Tests: 11 passed ✅ VERIFIED
# Expected with post-message-transport.ts and dev-client.ts restored to the parent branch: 7 failed (re-arm, timeout after the last keepalive, '*' posts, both sleep cases, the cap, origin learning), 4 passed (the "ignore" cases) ✅ VERIFIED
  • No browser QA: nothing in this repo sends a keepalive yet; the parent page that will send it lives outside this repo.

Blast Radius

  • No feature flag. Risk: Low. Only framed backend calls change, and only when the parent sends the new message.
  • A parent that never sends a keepalive sees the same 2-minute timeout as before; one that does can keep a call pending for up to 60 minutes.

Out of Scope / Follow-ups

1 item deferred
Item Status Next step
Send the keepalive from the parent page while its consent dialog is open Independent The parent page's owner adds it, using the README section

Documentation

🤖 Generated with Claude Code

@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 95492e6 | Docs | View more details | Give us feedback!

@tyffical
tyffical changed the base branch from tiffany.trinh/apps-2947-debug-bundle-connection-ids to tiffany.trinh/apps-2958-debug-bundle-call-inputs October 22, 2026 00:29
@tyffical
tyffical force-pushed the tiffany.trinh/apps-2958-frame-keepalive branch from b10e989 to 3e2ee44 Compare October 22, 2026 19:42
@tyffical
tyffical force-pushed the tiffany.trinh/apps-2958-debug-bundle-call-inputs branch from 768c620 to 7e7153c Compare October 23, 2026 05:20
@tyffical
tyffical force-pushed the tiffany.trinh/apps-2958-frame-keepalive branch from 3e2ee44 to 472048d Compare October 23, 2026 05:20
@tyffical
tyffical force-pushed the tiffany.trinh/apps-2958-debug-bundle-call-inputs branch from 7e7153c to 2806fd6 Compare October 23, 2026 14:53
@tyffical
tyffical force-pushed the tiffany.trinh/apps-2958-frame-keepalive branch from 472048d to 5b44ed1 Compare October 23, 2026 14:53
@tyffical
tyffical force-pushed the tiffany.trinh/apps-2958-debug-bundle-call-inputs branch from 2806fd6 to 1d9a0d3 Compare October 23, 2026 15:59
@tyffical
tyffical force-pushed the tiffany.trinh/apps-2958-frame-keepalive branch from 5b44ed1 to 182ea03 Compare October 23, 2026 15:59
The parent can post app-builder:run-query:keepalive with a pending call's
requestId to restart the frame's 2-minute wait, for example every 30
seconds while a consent dialog is open. A keepalive counts only from the
recipient a response would be accepted from, and a call still times out
60 minutes after it was posted. The cap is a safety net for a parent that
keeps a call alive but never answers, not a deadline for the user reading
a consent dialog. Both limits are wall-clock deadlines checked whenever
the timer fires or a keepalive arrives, so time the machine spends asleep
counts toward them. The dev client also learns the parent's origin from a
keepalive, as it does from a pong or response.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tyffical
tyffical force-pushed the tiffany.trinh/apps-2958-debug-bundle-call-inputs branch from 1d9a0d3 to 7649b0d Compare October 23, 2026 16:22
@tyffical
tyffical force-pushed the tiffany.trinh/apps-2958-frame-keepalive branch from 182ea03 to 95492e6 Compare October 23, 2026 16:22
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