-
Notifications
You must be signed in to change notification settings - Fork 962
fix: prevent postinstall infinite loop on bun install #1064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Kitenite
merged 1 commit into
superset-sh:main
from
spanishflu-est1918:fix/postinstall-infinite-loop
Jan 31, 2026
+17
−1
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/bin/bash | ||
| # Prevent infinite recursion during postinstall | ||
| # electron-builder install-app-deps can trigger nested bun installs | ||
| # which would re-run postinstall, spawning hundreds of processes | ||
|
|
||
| if [ -n "$SUPERSET_POSTINSTALL_RUNNING" ]; then | ||
| exit 0 | ||
| fi | ||
|
|
||
| export SUPERSET_POSTINSTALL_RUNNING=1 | ||
|
|
||
| # Run sherif for workspace validation | ||
| sherif | ||
|
|
||
| # Install native dependencies for desktop app | ||
| bun run --filter=@superset/desktop install:deps | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
🧩 Analysis chain
🌐 Web query:
bash strict mode set -e set -u set -o pipefail best practices error handling💡 Result:
What “strict mode” does (and what it doesn’t)
Common pattern:
set -euo pipefailset -e(errexit): exit when an unhandled command fails, but it is intentionally skipped in several contexts (tests inif/while/until, most&&/||lists, non-last pipeline elements unlesspipefail, and when status is inverted with!). So you still need explicit checks where you expect failures. [2]set -u(nounset): treat unset variables as an error. [1]set -o pipefail: a pipeline fails if any element fails (specifically: returns the last non‑zero status, or 0 if all succeed). Disabled by default. [1]Best-practice pattern (robust + debuggable errors)
1) Prefer explicit error handling + a trap, not blind reliance on
set -eUse a single error handler that prints context:
Why
-E? It helpsERRtraps propagate into functions/subshell contexts (without it, you’ll miss failures in places you thought were covered). [2]2) When failure is expected, handle it explicitly
Under
-e, don’t “probe” with commands that might fail unless you capture/branch on the status:This aligns with “always check return values” guidance. [3]
3) Be careful with
pipefail+ early-terminating consumers (head,grep -q)With
pipefail, producers can die withSIGPIPEwhen the downstream command exits early; that can abort your script even though the overall behavior is fine. You may need to explicitly allow it, or restructure:(Or avoid such pipelines / use tools designed for it.)
4) Avoid “hidden” errexit holes ShellCheck warns about
Example:
! cmdcan suppress errexit unexpectedly unless you explicitly exit/check status. [4]5) If you need POSIX
sh, don’t usepipefailpipefailis not POSIX; either require bash, or implement an alternative. [5]Key takeaway
set -euo pipefailis a good baseline, but robust Bash comes from: (a) explicit checks where failure is expected, (b) anERRtrap for actionable diagnostics, and (c) knowing the documented contexts whereerrexit/pipefaildon’t behave like exceptions. [1][2][3]Sources: GNU Bash manual for
pipefail/nounsetand errexit/ERR-trap exceptions [1][2], Google Shell Style Guide on checking return values and error reporting [3], ShellCheck wiki on!vserrexitand portability ofpipefail[4][5].🏁 Script executed:
# First, let's see the full postinstall.sh file to understand the complete context cat -n scripts/postinstall.shRepository: superset-sh/superset
Length of output: 609
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 205
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 653
🏁 Script executed:
# Check if other scripts in the same location use set -e or strict mode head -5 scripts/lint.shRepository: superset-sh/superset
Length of output: 204
🏁 Script executed:
# Check the desktop build script for comparison head -10 apps/desktop/create-release.shRepository: superset-sh/superset
Length of output: 407
Fail fast on sherif/bun errors (enable strict mode).
Without
set -e(and ideally-u -o pipefail), a failedsherifcommand will not terminate the script, allowing subsequent commands to execute even after validation fails. Since this script runs as an npm/bun postinstall hook, such failures should halt the installation. Add strict mode to catch errors early.♻️ Proposed change
📝 Committable suggestion
🤖 Prompt for AI Agents