Skip to content

Add JSON streaming to app function replay watch mode - #9007

Draft
gonzaloriestra wants to merge 1 commit into
mainfrom
gonzalo/function-replay-stream
Draft

gonzaloriestra wants to merge 1 commit into
mainfrom
gonzalo/function-replay-stream

Conversation

@gonzaloriestra

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Fixes https://github.com/shop/issues-develop/issues/24315.

Function replay watches by default, but currently rejects --json unless --no-watch is supplied.

WHAT is this pull request doing?

Add a typed JSONL watch stream with lifecycle, rebuild, and execution records. Keep diagnostics on stderr and preserve native runner fields and numeric tokens inside execution results. Recoverable build and Function failures keep watching; fatal failures stop the session. Cancellation waits for the watcher, builds, and runner to finish.

The finite --no-watch --json result and text watch UI stay compatible. Help and schema discovery describe both output modes.

Representative text output:

Input
{}
Output
{"operations":[]}

JSON watch output:

{"type":"status","timestamp":"2026-10-26T09:00:00Z","status":"watching"}
{"type":"execution","timestamp":"2026-10-26T09:00:00Z","result":{"name":"function.wasm","size":1,"memory_usage":64,"instructions":1000,"logs":"","input":{},"output":{"operations":[]},"success":true},"exitCode":0}

Validation: 154 focused tests, affected TypeScript and lint checks, CLI build, schema discovery, and generated command artifacts. Regression checks also fail when native numeric tokens are re-encoded. Watch events and runner operations are controlled in contract tests; no live-store replay was run.

How to manually test your changes?

  1. In an app with a saved Function log, run pnpm shopify app function replay --path <function-directory> --log <log-identifier> --json --no-input > replay.jsonl 2> replay.stderr.
  2. Edit the Function, introduce a build error, then fix it. Check that stdout contains separate records and stderr contains diagnostics while replay keeps watching.
  3. Press Ctrl-C. Check the cancellation record and exit code 130. Repeat with --no-watch --json to inspect the single native result, and without --json to inspect the terminal UI.
  4. Run pnpm shopify app function replay --json-schema to inspect both contracts without starting replay.

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing — I've identified the correct bump types and added a changeset (minor for CLI streaming support, patch for CLI Kit process cancellation).

@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label Oct 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: @shopify/cli @shopify/cli package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant