build(mac): split bundle step and capture stderr for diagnostics#9965
build(mac): split bundle step and capture stderr for diagnostics#9965asheshv wants to merge 1 commit into
Conversation
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.
WalkthroughBuild 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. ChangesFrontend Build Sequence Refactoring
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
pkg/mac/build-functions.sh
| 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 |
There was a problem hiding this comment.
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.
| 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.
| yarn run linter 2>&1 | ||
| echo "==> Running webpack bundle..." | ||
| yarn run webpacker 2>&1 |
There was a problem hiding this comment.
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.
Summary
yarn run bundlewith zero console output — the Jenkins log jumps fromyarn install ... Done with warningsstraight 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 onpgabf-macos-x64(arm64 of the same commit passed cleanly).yarn run bundlecall inpkg/mac/build-functions.sh::_complete_bundlewith its individual steps, with stderr merged to stdout and a stage marker echoed before each, so the next failure is diagnosable:NODE_ENV=productionandNODE_OPTIONS=--max-old-space-size=3072are exported explicitly to mirror thecross-envwrapper inside the top-levelbundlenpm script, so build output stays byte-identical to before.No-op for successful builds; pure diagnostics win on failure.
Test plan
pgadmin4-macos-qaon bothmacos-x64andmacos-arm64and confirm the appbundle still builds successfully.==> Running ...markers appear in order, followed by the usual<s> [webpack.Progress] …lines..jsx) and confirm the error text now reaches the console between the==> Running webpack bundle...marker and the EXIT trap message.Summary by CodeRabbit