Skip to content

build(mac): split bundle step and capture stderr for diagnostics#9965

Open
asheshv wants to merge 1 commit into
masterfrom
fix/mac-bundle-diagnostics
Open

build(mac): split bundle step and capture stderr for diagnostics#9965
asheshv wants to merge 1 commit into
masterfrom
fix/mac-bundle-diagnostics

Conversation

@asheshv
Copy link
Copy Markdown
Contributor

@asheshv asheshv commented May 21, 2026

Summary

  • macOS x64 appbundle builds can fail inside yarn run bundle with zero console output — the Jenkins log jumps from yarn install ... Done with warnings straight to the EXIT trap's failure message, leaving no signal as to whether linter, webpack, or a native module load was the culprit. Prompted by build #1293 on pgabf-macos-x64 (arm64 of the same commit passed cleanly).
  • Replace the monolithic yarn run bundle call in pkg/mac/build-functions.sh::_complete_bundle with its individual steps, with stderr merged to stdout and a stage marker echoed before each, so the next failure is diagnosable:
    yarn install
    yarn run git:hash    # cheap source-hash capture, moved up front
    yarn run linter
    yarn run webpacker
    
  • NODE_ENV=production and NODE_OPTIONS=--max-old-space-size=3072 are exported explicitly to mirror the cross-env wrapper inside the top-level bundle npm script, so build output stays byte-identical to before.

No-op for successful builds; pure diagnostics win on failure.

Test plan

  • Trigger pgadmin4-macos-qa on both macos-x64 and macos-arm64 and confirm the appbundle still builds successfully.
  • Inspect the Jenkins console of a passing build and verify the new ==> Running ... markers appear in order, followed by the usual <s> [webpack.Progress] … lines.
  • (Optional) Force a webpack failure locally (e.g. introduce a syntax error in a .jsx) and confirm the error text now reaches the console between the ==> Running webpack bundle... marker and the EXIT trap message.

Summary by CodeRabbit

  • Chores
    • Optimized the web frontend build process for improved reliability and error visibility, with separated build steps and enhanced logging during compilation.

Review Change Stack

The macOS x64 appbundle build can fail inside `yarn run bundle` while
producing zero console output -- the Jenkins log goes straight from
"yarn install ... Done with warnings" to the EXIT trap's failure
message, leaving no signal as to whether linter, webpack, or a native
module load was the culprit (build #1293 on pgabf-macos-x64 is the
prompting example).

Split the bundled script into its constituent steps and merge stderr
into stdout so any error text reaches the console even if Jenkins'
shell step drops a tail buffer:

  yarn install
  yarn run git:hash    # cheap source-hash capture, moved up front
  yarn run linter
  yarn run webpacker

`git:hash` is a pure `git log` redirect (see web/package.json) with no
node-module dependency, but `yarn run` needs node_modules so it stays
after install. Pulling it before the heavy steps means the commit_hash
file lands on disk even if webpack later bails out.

Env vars NODE_ENV=production and NODE_OPTIONS=--max-old-space-size=3072
are set explicitly to mirror the cross-env wrapper inside the top-level
"bundle" npm script, so build output stays byte-identical to before.

No-op for successful builds; pure diagnostics win on failure.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

Walkthrough

Build script refactored to separate the frontend build sequence into discrete steps: yarn install, git hash recording, linting, and webpack bundling with explicit environment configuration. NODE_ENV and NODE_OPTIONS are set during linting/bundling then unset afterward, improving console output visibility during these operations.

Changes

Frontend Build Sequence Refactoring

Layer / File(s) Summary
Frontend build sequence with environment management
pkg/mac/build-functions.sh
Yarn install step merges stdout/stderr, followed by git hash recording, then separate linting and webpack bundling commands each configured with NODE_ENV=production and increased memory limit. Environment variables are unset after bundling completes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 accurately describes the main change: splitting the bundle step and capturing stderr for diagnostics, which aligns with the core modifications to the build sequence.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 fix/mac-bundle-diagnostics

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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 `@pkg/mac/build-functions.sh`:
- Around line 294-302: Add explicit failure handling to the two commands that
currently lack it: ensure the "yarn install 2>&1" invocation and the "yarn run
git:hash" invocation both propagate errors (e.g., append "|| exit 1") so the
script fails fast on install or git:hash errors; update the calls where found in
build-functions.sh to match the existing error-handling pattern used elsewhere
(see the earlier commands that use "|| exit 1") so subsequent build steps don't
run on a broken state.
- Around line 313-315: The yarn commands for linting and webpacking currently
run without checking failure: ensure the build stops on errors by adding
explicit error handling for the two invocations (the lines running "yarn run
linter" and "yarn run webpacker"): either enable a fail-fast shell option (e.g.,
set -e at the top of the script) or append a check to each command so that if
"yarn run linter" or "yarn run webpacker" exits non‑zero you print a clear error
and exit 1 (e.g., use "yarn run linter" ... || { echo 'Lint failed'; exit 1; }
and similarly for "yarn run webpacker") so the build cannot continue with failed
lint or bundle steps.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dd41138a-4693-402f-8506-08579a0aafa2

📥 Commits

Reviewing files that changed from the base of the PR and between ae6dc4b and 4e1a8d1.

📒 Files selected for processing (1)
  • pkg/mac/build-functions.sh

Comment on lines +294 to +302
yarn install 2>&1

# Record the source commit hash before the heavy lint/webpack
# steps. `yarn run` needs node_modules so this runs after install,
# but it's a pure `git log` redirect (see web/package.json
# "git:hash") that costs ~nothing, so doing it up front means the
# commit_hash file is captured even if webpack later bails out.
echo "==> Recording git hash..."
yarn run git:hash
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Add error handling for yarn install and yarn run git:hash.

Both commands lack explicit error handling (e.g., || exit 1). If yarn install fails, subsequent build steps will operate on broken or incomplete dependencies, producing unusable artifacts. The git:hash step is less critical but should still fail fast if it cannot complete.

Other critical commands in this file (lines 92–93) follow the || exit 1 pattern. Apply the same here to maintain consistency and ensure build failures are caught immediately.

🛡️ Proposed fix to add error handling
-        yarn install 2>&1
+        yarn install 2>&1 || exit 1
 
         # Record the source commit hash before the heavy lint/webpack
         # steps. `yarn run` needs node_modules so this runs after install,
         # but it's a pure `git log` redirect (see web/package.json
         # "git:hash") that costs ~nothing, so doing it up front means the
         # commit_hash file is captured even if webpack later bails out.
         echo "==> Recording git hash..."
-        yarn run git:hash
+        yarn run git:hash || exit 1
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
yarn install 2>&1
# Record the source commit hash before the heavy lint/webpack
# steps. `yarn run` needs node_modules so this runs after install,
# but it's a pure `git log` redirect (see web/package.json
# "git:hash") that costs ~nothing, so doing it up front means the
# commit_hash file is captured even if webpack later bails out.
echo "==> Recording git hash..."
yarn run git:hash
yarn install 2>&1 || exit 1
# Record the source commit hash before the heavy lint/webpack
# steps. `yarn run` needs node_modules so this runs after install,
# but it's a pure `git log` redirect (see web/package.json
# "git:hash") that costs ~nothing, so doing it up front means the
# commit_hash file is captured even if webpack later bails out.
echo "==> Recording git hash..."
yarn run git:hash || exit 1
🤖 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 `@pkg/mac/build-functions.sh` around lines 294 - 302, Add explicit failure
handling to the two commands that currently lack it: ensure the "yarn install
2>&1" invocation and the "yarn run git:hash" invocation both propagate errors
(e.g., append "|| exit 1") so the script fails fast on install or git:hash
errors; update the calls where found in build-functions.sh to match the existing
error-handling pattern used elsewhere (see the earlier commands that use "||
exit 1") so subsequent build steps don't run on a broken state.

Comment on lines +313 to +315
yarn run linter 2>&1
echo "==> Running webpack bundle..."
yarn run webpacker 2>&1
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Add error handling for yarn run linter and yarn run webpacker.

If either linting or webpack bundling fails, the build should stop immediately. Without explicit error handling, the script will continue after failures and produce incomplete or broken build artifacts.

Linting failures indicate code quality issues that should block release, and webpack failures mean the frontend bundle is missing or corrupted. Both are critical build gates.

🛡️ Proposed fix to add error handling
         echo "==> Running ESLint..."
-        yarn run linter 2>&1
+        yarn run linter 2>&1 || exit 1
         echo "==> Running webpack bundle..."
-        yarn run webpacker 2>&1
+        yarn run webpacker 2>&1 || exit 1
         unset NODE_ENV NODE_OPTIONS
🤖 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 `@pkg/mac/build-functions.sh` around lines 313 - 315, The yarn commands for
linting and webpacking currently run without checking failure: ensure the build
stops on errors by adding explicit error handling for the two invocations (the
lines running "yarn run linter" and "yarn run webpacker"): either enable a
fail-fast shell option (e.g., set -e at the top of the script) or append a check
to each command so that if "yarn run linter" or "yarn run webpacker" exits
non‑zero you print a clear error and exit 1 (e.g., use "yarn run linter" ... ||
{ echo 'Lint failed'; exit 1; } and similarly for "yarn run webpacker") so the
build cannot continue with failed lint or bundle steps.

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