Skip to content

fix: silence zip output when creating source zips#8323

Open
ndhoule wants to merge 1 commit into
mainfrom
nathanhoule/ex-2434-intermittent-zip-r-failure-when-deploying-swar-projects
Open

fix: silence zip output when creating source zips#8323
ndhoule wants to merge 1 commit into
mainfrom
nathanhoule/ex-2434-intermittent-zip-r-failure-when-deploying-swar-projects

Conversation

@ndhoule

@ndhoule ndhoule commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

This code path is the cause of a bunch of SWAR errors. Logs don't
provide enough information for us to debug this right now, so this PR
does two things:

  • Adds the -q flag to zip to quiet its output. (We pass this flag
    everywhere else we call out to zip.) I have a weak suspicion the
    root cause here could be a too-much-output error (but that seems
    unlikely).
  • Improves the error output when we hit this error. This should let us
    debug the issue if it comes up again in the future.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved source-zip creation reliability and error reporting during deploy uploads.
    • Better surfaced command failures with clearer output, making upload issues easier to diagnose.
    • Updated cleanup handling to work more consistently after zip operations.
  • Tests

    • Adjusted unit coverage to match the new zip execution flow and failure handling.
    • Verified command arguments, working directory setup, and error propagation behavior.

Walkthrough

upload-source-zip.ts now runs zip through execa, captures its output, and rethrows failures with a message built from ExecaError.shortMessage and stdout. Temporary zip cleanup now imports unlink from node:fs/promises. The unit tests were updated to mock execa instead of child_process.execFile, and their assertions now check the new zip arguments, error path, cleanup path, and path-based filename case.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: silencing zip output during source-zip creation.
Description check ✅ Passed The description is directly about quieting zip output and improving error reporting for the same code path.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch nathanhoule/ex-2434-intermittent-zip-r-failure-when-deploying-swar-projects

Comment @coderabbitai help to get the list of available commands.

@ndhoule ndhoule force-pushed the nathanhoule/ex-2434-intermittent-zip-r-failure-when-deploying-swar-projects branch from ebb6bdf to 78c34c2 Compare June 26, 2026 16:33
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown

📊 Benchmark results

Comparing with 137fbf0

  • Dependency count: 1,127 (no change)
  • Package size: 379 MB (no change)
  • Number of ts-expect-error directives: 359 ⬆️ 1.95% increase vs. 137fbf0

@ndhoule ndhoule force-pushed the nathanhoule/ex-2434-intermittent-zip-r-failure-when-deploying-swar-projects branch 2 times, most recently from 474a2d4 to b915667 Compare June 26, 2026 16:47
This code path is the cause of a bunch of SWAR errors. Logs don't
provide enough information for us to debug this right now, so this PR
does two things:

- Adds the `-q` flag to `zip` to quiet its output. (We pass this flag
  everywhere else we call out to `zip`.) I have a weak suspicion the
  root cause here could be a too-much-output error (but that seems
  unlikely).
- Improves the error output when we hit this error. This should let us
  debug the issue if it comes up again in the future.
@ndhoule ndhoule force-pushed the nathanhoule/ex-2434-intermittent-zip-r-failure-when-deploying-swar-projects branch from b915667 to b9049ab Compare June 26, 2026 17:56
@ndhoule ndhoule marked this pull request as ready for review June 26, 2026 19:09
@ndhoule ndhoule requested a review from a team as a code owner June 26, 2026 19:09

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/unit/utils/deploy/upload-source-zip.test.ts (1)

335-338: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Inconsistent mock return type across tests.

These two execa mocks return a synchronous {} as ExecaReturnValue, whereas the other tests (Lines 64, 127, 286) return Promise.resolve(...). The awaited call tolerates both, but aligning them avoids confusion about what execa resolves to.

♻️ Optional alignment
-    vi.mocked(mockExeca.default).mockImplementation((..._args) => {
-      return {} as ExecaReturnValue
-    })
+    vi.mocked(mockExeca.default).mockImplementation((..._args) => {
+      return Promise.resolve({} as ExecaReturnValue)
+    })

Also applies to: 374-377

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/utils/deploy/upload-source-zip.test.ts` around lines 335 - 338,
The execa mocks in the upload-source-zip tests are inconsistent with the other
cases, returning a synchronous cast instead of a resolved promise. Update the
mockImplementation blocks for the affected execa stubs to match the existing
Promise.resolve pattern used elsewhere in upload-source-zip.test.ts, so the
mocked behavior is consistent across all tests and easier to understand.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/utils/deploy/upload-source-zip.ts`:
- Around line 76-89: The zip upload error handling in upload-source-zip should
use the combined execa output instead of stdout alone, since zip -q often leaves
stdout empty. Update the catch block around the execa call to build the thrown
Error message from the ExecaError details using the interleaved output first,
then stderr as fallback, and keep the existing cause chaining. Use the existing
execa invocation and ExecaError handling in upload-source-zip.ts as the place to
make this change.

---

Nitpick comments:
In `@tests/unit/utils/deploy/upload-source-zip.test.ts`:
- Around line 335-338: The execa mocks in the upload-source-zip tests are
inconsistent with the other cases, returning a synchronous cast instead of a
resolved promise. Update the mockImplementation blocks for the affected execa
stubs to match the existing Promise.resolve pattern used elsewhere in
upload-source-zip.test.ts, so the mocked behavior is consistent across all tests
and easier to understand.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e33820fe-c445-48ee-b472-90460211264a

📥 Commits

Reviewing files that changed from the base of the PR and between 137fbf0 and b9049ab.

📒 Files selected for processing (2)
  • src/utils/deploy/upload-source-zip.ts
  • tests/unit/utils/deploy/upload-source-zip.test.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • netlify/blueprints (manual)

Comment thread src/utils/deploy/upload-source-zip.ts
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