Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions scripts/build-vercel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ WEB="${2:-web}"
OUT="${3:-out}"
JS="index.js worker.js async.js bindings.js protocol.js status.js platform.js"

# Content-hashed dir name covering the mt engine files, so any engine change busts the
# immutable cache. 16 hex chars (64 bits) keep collisions negligible.
HASH_INPUT=""
for f in $JS chdb.mjs chdb.wasm; do HASH_INPUT="$HASH_INPUT $DIST/$f"; done
VER="dist-$(cat $HASH_INPUT | md5sum | cut -c1-16)"
# Cache-busting dir name = the installed engine's version. npm versions are immutable, so
# the version fully identifies the engine bytes: a new engine => new version => new dir =>
# fresh fetch, with no stale-cache risk. Computed with node (always present in a Vercel
# build) rather than md5sum, which the build image does not ship.
VER="dist-$(node -pe "JSON.parse(require('fs').readFileSync('$(dirname "$DIST")/package.json','utf8')).version")"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium scripts/build-vercel.sh:32

Line 32 reads package.json from $(dirname "$DIST") to compute VER, but when $DIST is a standalone asset directory like ./dist, dirname resolves to . and the script reads this repo's unrelated package.json (yielding 0.0.0) or throws ENOENT when no parent package.json exists. This produces the wrong cache-busting directory or aborts the build for non-default invocations, breaking the [dist-dir] argument that the previous implementation supported.

🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @scripts/build-vercel.sh around line 32:

Line 32 reads `package.json` from `$(dirname "$DIST")` to compute `VER`, but when `$DIST` is a standalone asset directory like `./dist`, `dirname` resolves to `.` and the script reads this repo's unrelated `package.json` (yielding `0.0.0`) or throws `ENOENT` when no parent `package.json` exists. This produces the wrong cache-busting directory or aborts the build for non-default invocations, breaking the `[dist-dir]` argument that the previous implementation supported.


rm -rf "$OUT"
mkdir -p "$OUT/$VER"
Expand Down
Loading