Skip to content

fix(cli): wait for the postInstall script before qwik add exits - #9371

Merged
Varixo merged 2 commits into
QwikDev:mainfrom
ankur-arch:fix/cli-await-post-install
Nov 4, 2026
Merged

Varixo merged 2 commits into
QwikDev:mainfrom
ankur-arch:fix/cli-await-post-install

Conversation

@ankur-arch

@ankur-arch ankur-arch commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

What is it?

  • Bugfix

Description

qwik add <integration> returns from the integration's postInstall script before that script has finished. runInPkg returns { install, abort } synchronously, and runAddInteractive awaits the object instead of the install promise, so the spinner prints "Post install script complete" and the process hits process.exit(0) while the child is still running. The child is killed with it.

Three starters declare a postInstall today: playwright install, panda codegen --silent, and the Prisma starter's prisma contract emit (prisma migrate dev --name initial before #9358). None of them can finish unless they complete within a few milliseconds, and a failing script is never reported.

Change

  • Await the install promise, the same way check-client already does.
  • When the command exits non-zero: stop the spinner with Post install script failed: <script>, print an "Action Required" note with the command to rerun (npx <script> for npm, <pkgManager> <script> otherwise), and exit with status 1 instead of printing the Success footer. runCommand already logs the execa error above it.

How I tested it

Built the CLI from this branch (pnpm build.cli) and ran qwik add prisma --skipConfirmation=true against a fresh npm create qwik@rc -- empty app (Qwik 2.0.0-rc.4, Node 24.11.1, npm 11.6.2), with the Prisma starter from #9358 copied into dist/starters:

  • Before the fix: the CLI prints "Post install script complete" and exits, and prisma/contract.json is never written.
  • After the fix: the spinner runs for a couple of seconds, prisma/contract.json and prisma/contract.d.ts exist when the CLI exits, and npm run build passes.
  • With the starter's postInstall edited to prisma no-such-command: the CLI logs Command failed with exit code 2: npx prisma no-such-command, stops the spinner with "Post install script failed: prisma no-such-command", prints the Action Required note with npx prisma no-such-command, does not print the Success footer, and exits with status 1.
  • pnpm vitest run packages/qwik/src/cli: 152 tests pass.

#9358 depends on this: its postInstall generates the files the starter's prisma/db.ts imports.

Checklist

  • My code follows the developer guidelines of this project
  • I performed a self-review of my own code
  • I added a changeset with pnpm change
  • I made corresponding changes to the Qwik docs (not needed)

@ankur-arch
ankur-arch requested a review from a team as a code owner November 3, 2026 14:50
@changeset-bot

changeset-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a3279bf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@qwik.dev/core Patch
@qwik.dev/devtools Patch
eslint-plugin-qwik Patch
@qwik.dev/mcp Patch
@qwik.dev/react Patch
@qwik.dev/router Patch
@qwik.dev/utils Patch
create-qwik Patch

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

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The interactive qwik add flow now checks the post-install result. On success, it reports completion. On failure, it displays a rerun command and exits with status 1. A patch changeset describes this behavior.

Changes: Post-install reporting

Layer / File(s) Summary
Post-install result handling
packages/qwik/src/cli/add/run-add-interactive.ts, .changeset/fix-cli-await-post-install.md
The flow reports completion when the post-install command succeeds. On failure, it displays a red failure message and a rerun command, then exits with status 1. The changeset describes this behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • QwikDev/qwik#9358: Adds a Prisma postInstall command that relies on qwik add waiting for post-install work to finish.

Suggested reviewers: shairez, manucorporat

Merge Risk: Minimal · up to a3279

The CLI now waits for post-install completion and correctly reports successful and failed commands.

Security architecture risk: Low · up to a3279

The CLI now waits for integration setup and reports failure accurately without changing how commands are selected or executed. Setup remains non-transactional: a failed script can leave partial changes, and safe recovery depends on that script.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed behavior affects the selected integration script’s opportunity to finish and the CLI’s reported outcome. No additional command source, execution target, or privilege mechanism is introduced by the compared change.

Trust Boundaries and Controls

  • observed — The existing integration lookup and confirmation flow remain ahead of commit and script execution. The changed branch does not bypass those steps or pass the CLI integration identifier directly as a command.

Resilience and Maintainability Implications

  • inferred — The non-transactional ordering predates this PR. Accurate failure reporting improves visibility, but the caller does not establish that a partly executed external script can safely be repeated or that interruption leaves recoverable state. These remain recovery uncertainties rather than verified introduced security findings.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(cli): wait for the postInstall script before qwik add exits" matches the main change. The changeset and run-add-interactive.ts changes make runAddInteractive await the postInstall scrip…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(cli): wait for the postInstall script before qwik add exits" matches the main change. The changeset and run-add-interactive.ts changes make runAddInteractive await the postInstall script's install promise, report success or failure, and exit with status 1 on failure. The title names the CLI, the postInstall wait, and the qwik add command, so it describes the primary fix. It is concise, specific, and follows a conventional commit prefix. It is 63 characters long, which is within a normal title length.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f9bed805-dc08-4ed4-86f2-72530f94d56a
Commits

Reviewing files that changed from the base of the PR and between 6dd1965 and a3279bf.

Files selected for processing: 1
  • packages/qwik/src/cli/add/run-add-interactive.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Fix comments: Fix CodeRabbit comments on this PR

@Varixo Varixo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Varixo
Varixo enabled auto-merge November 4, 2026 13:47
@pkg-pr-new

pkg-pr-new Bot commented Nov 4, 2026

Copy link
Copy Markdown

Open in StackBlitz

@qwik.dev/core

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/core@9371

@qwik.dev/router

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/router@9371

@qwik.dev/utils

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/utils@9371

eslint-plugin-qwik

npm i https://pkg.pr.new/QwikDev/qwik/eslint-plugin-qwik@9371

create-qwik

npm i https://pkg.pr.new/QwikDev/qwik/create-qwik@9371

@qwik.dev/optimizer

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/optimizer@9371

@qwik.dev/devtools

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/devtools@9371

@qwik.dev/mcp

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/mcp@9371

commit: a3279bf

@Varixo
Varixo merged commit a0da540 into QwikDev:main Nov 4, 2026
55 checks passed
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

⚡ Docs preview for a3279bf

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.

2 participants