From 4e1a8d1897c61dcaadbbca58646583a2f063baa5 Mon Sep 17 00:00:00 2001 From: Ashesh Vashi Date: Wed, 20 May 2026 19:50:35 +0530 Subject: [PATCH] build(mac): split bundle step and capture stderr for diagnostics 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. --- pkg/mac/build-functions.sh | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/pkg/mac/build-functions.sh b/pkg/mac/build-functions.sh index de94b8ba87d..de0f89318a7 100644 --- a/pkg/mac/build-functions.sh +++ b/pkg/mac/build-functions.sh @@ -291,8 +291,29 @@ _complete_bundle() { pushd "${SOURCE_DIR}/web" > /dev/null || exit yarn set version berry yarn set version 4 - yarn install - yarn run bundle + 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 + + # Split the "bundle" script into its underlying steps and merge + # stderr into stdout, so a crash inside lint/webpack (e.g. an OOM + # kill or native-module load failure) leaves a trace in the + # Jenkins console instead of an empty gap before the trap fires. + # Env vars match the top-level "bundle" npm script (see web/package.json) + # so behavior is identical to `yarn run bundle`. + export NODE_ENV=production + export NODE_OPTIONS=--max-old-space-size=3072 + echo "==> Running ESLint..." + yarn run linter 2>&1 + echo "==> Running webpack bundle..." + yarn run webpacker 2>&1 + unset NODE_ENV NODE_OPTIONS curl https://curl.se/ca/cacert.pem -o cacert.pem -s popd > /dev/null || exit