Skip to content

Fix Function replay shutdown and process cancellation - #9057

Draft
isaacroldan wants to merge 1 commit into
codex/function-replay-jsonfrom
codex/function-replay-shutdown
Draft

isaacroldan wants to merge 1 commit into
codex/function-replay-jsonfrom
codex/function-replay-shutdown

Conversation

@isaacroldan

@isaacroldan isaacroldan commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Ctrl-C should stop active Function execution and queued rebuilds before replay finishes. The first PR in this stack adds JSON output but leaves shared build and process shutdown behavior unchanged.

WHAT is this pull request doing?

Move the shutdown fixes from #9007 into this separate change. The original PR remains unchanged.

  • Cancel active runner processes and build-lock waits, and prevent queued builds from starting after cancellation.
  • Close the file watcher, clear its pending timers, and wait for active rebuilds and executions before writing the final cancellation record.
  • Wait for captured child processes to exit after cancellation and remove process abort listeners after execution.

This PR is based on codex/function-replay-json; its diff contains the shutdown fixes and their tests, not the JSON feature again. Runner cancellation and watcher cleanup apply to the shared replay loop used by both JSON output and the text UI.

How to manually test your changes?

Use an app with a Function and a saved Function log.

  1. Run pnpm shopify app function replay --path <function-directory> --log <log-id> --json --no-input.
  2. Edit the Function to start a rebuild. Press Ctrl-C while the build or runner is active. Check that the active work stops, the final record is cancelled, and the command exits with code 130.
  3. Repeat with a build waiting for another process to release .build-lock. Cancel replay, then release the lock. Check that no new build starts.
  4. Repeat without --json to check that text replay still works. Use --no-watch --json to check the single-result output.

Validation

  • After updating the base: 308 Function, replay, build, and watcher tests and 65 CLI-kit process tests passed.
  • App and CLI-kit type-checks and builds passed. ESLint passed; the Nx module-boundary rule was skipped because the isolated checkout has no cached project graph.
  • The full CLI recovery flow passed with a real file watcher and a controlled Node runner.
  • A CLI probe with a child that takes 700 ms to handle SIGTERM confirmed that cleanup finishes before both the cancelled record and exit code 130.
  • Lower-level build, watcher, runner, and process changes are unchanged from the original shutdown commit. Replay cleanup now runs in the shared loop; JSON signal handling stays in its output adapter.
  • Native WASM execution remains unverified: Function runner 9.2.2 receives SIGKILL on this machine even for --version.

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 and has patch changesets for CLI and CLI Kit.

@isaacroldan
isaacroldan added this pull request to stack #9058 November 2, 2026 13:19
@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label Nov 2, 2026
@isaacroldan
isaacroldan force-pushed the codex/function-replay-shutdown branch 5 times, most recently from f8ab107 to dc6793d Compare November 3, 2026 13:06
@isaacroldan
isaacroldan force-pushed the codex/function-replay-shutdown branch 2 times, most recently from 4cd3f94 to 6360547 Compare November 3, 2026 13:21
@isaacroldan
isaacroldan force-pushed the codex/function-replay-shutdown branch from 6360547 to 6c7547f Compare November 4, 2026 12:51

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