Skip to content

build-vercel.sh: hash engine files for the cache dir (restore [dist-dir] support) - #8

Merged
wudidapaopao merged 2 commits into
mainfrom
fix-build-hash
Jul 1, 2026
Merged

wudidapaopao merged 2 commits into
mainfrom
fix-build-hash

Conversation

@wudidapaopao

@wudidapaopao wudidapaopao commented Jul 1, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to the exit-127 fix. Review flagged that computing VER from
$(dirname "$DIST")/package.json only works for the default DIST
(node_modules/chdb-wasm/dist); for any other [dist-dir] arg, dirname points elsewhere
and reads this repo's package.json (0.0.0) or throws ENOENT.

Fix: hash the mt engine files (glue + wasm) with node's crypto instead of a version lookup.

  • Still md5sum-free (the Vercel image doesn't ship it).
  • Still content-based — any engine change busts the immutable cache.
  • Works for any DIST dir, restoring the [dist-dir] argument.
  • The 16-char digest is identical to cat <files> | md5sum.

Verified locally: default invocation, a non-default standalone dist dir, and hash-equals-md5sum.

🤖 Generated with Claude Code

Note

Replace version-based cache dir naming with content hash of engine files in build-vercel.sh

The cache directory name (VER) is now derived from an MD5 hash of the engine files ($JS, chdb.mjs, chdb.wasm) instead of the package.json version, so cache invalidation tracks actual file changes rather than version bumps.

  • Introduces an ENGINE_FILES array collecting $DIST-prefixed paths for the relevant files.
  • Computes VER as dist- followed by the first 16 hex chars of the MD5 hash via a Node one-liner.
  • Removes the previous Node command that read the version from package.json.
  • Behavioral Change: the output directory name under $OUT will differ from previous runs, invalidating any existing caches on next deploy.

Macroscope summarized 1eb81bf.

Addresses review feedback: deriving VER from $(dirname "$DIST")/package.json only works
when DIST is node_modules/chdb-wasm/dist. For any other [dist-dir] arg (e.g. ./dist or a
standalone engine dir) dirname points elsewhere, reading this repo's package.json (0.0.0)
or hitting ENOENT — breaking the [dist-dir] argument.

Hash the actual mt engine files with node's crypto instead: still md5sum-free (fixes the
exit-127 Vercel build), still content-based (any engine change busts the cache), and works
for any DIST dir. The 16-char digest matches `cat <files> | md5sum`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread scripts/build-vercel.sh Outdated
Review follow-up: the unquoted $ENGINE_FILES expansion word-splits when DIST contains a
space, so node received path fragments. Build the list as a bash array and expand it
quoted ("${ENGINE_FILES[@]}") so each full path is preserved.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chdb-wasm Ready Ready Preview, Comment Jul 1, 2026 6:21am

Request Review

@wudidapaopao
wudidapaopao merged commit b03ced7 into main Jul 1, 2026
5 checks passed

This branch was successfully deployed

1 active deployment
Preview — 1eb81bf2 Deployed Jul 1, 2026 by vercel[bot]
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