Skip to content

fix: handle StaticSitesClient stderr and non-zero exit codes#988

Closed
LongOddCode wants to merge 3 commits intoAzure:mainfrom
LongOddCode:developer/LongOddCode/fix-swa-deploy-silent-failure
Closed

fix: handle StaticSitesClient stderr and non-zero exit codes#988
LongOddCode wants to merge 3 commits intoAzure:mainfrom
LongOddCode:developer/LongOddCode/fix-swa-deploy-silent-failure

Conversation

@LongOddCode
Copy link
Copy Markdown
Contributor

Problem

The swa deploy command silently ignores failures from the StaticSitesClient binary. When the binary crashes (e.g., missing native dependencies on node:22-slim Docker images), the CLI reports success and exits with code 0. This causes CI/CD pipelines to mark deployments as succeeded when no content was actually uploaded.

Root Cause

Three bugs in src/cli/commands/deploy/deploy.ts:

  1. No stderr handlingchild.stderr is never read; all binary errors are silently discarded
  2. No non-zero exit code handlingchild.on("close") only handles code === 0; no else branch
  3. No exit code propagation — CLI never calls process.exit(1) on failure; CI sees exit 0

Fix

  • Adds child.stderr.on("data", ...) handler to capture and log binary errors
  • Adds else branch for non-zero exit codes with a diagnostic message suggesting ldd to check for missing shared libraries
  • Calls process.exit(1) on failure so CI/CD pipelines correctly detect deployment failures

Impact

This is a known issue since July 2022 affecting multiple CI/CD platforms:

Testing

  • tsc --noEmit passes
  • Changes are isolated to the error handling path; no impact on successful deployments

The deploy command silently ignored failures from the StaticSitesClient
binary. When the binary crashed (e.g., missing native dependencies on
slim Docker images), the CLI reported success and exited with code 0.

This fix:
- Adds stderr handler to capture binary error output
- Adds else branch for non-zero exit codes with diagnostic message
- Calls process.exit(1) on failure so CI/CD detects it

Fixes Azure#536, Azure#594
Refs: ICM 21000000909499
- stderr is captured and passed to logger.error
- Non-zero exit code triggers spinner.fail and error message
- process.exit(1) is called on binary failure
- Success path (exit code 0) remains unchanged
The ReturnType<typeof vi.spyOn> didn't match the 'never' return type of
process.exit, causing tsc to fail in CI format check.
@LongOddCode
Copy link
Copy Markdown
Contributor Author

Closing fork-based PR. Reopening as direct branch PR for CI with secrets.

@LongOddCode LongOddCode closed this Apr 9, 2026
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.

Azure Static Web app deployes locally but not in CI/CD CircleCI GitLab CI/CD deployment with SWA does not execute properly

1 participant