Skip to content

Use chdb npm runtime for local mode - #791

Open
ShawnChen-Sirius wants to merge 1 commit into
MapleTechLabs:mainfrom
ShawnChen-Sirius:codex/maple-chdb-npm-runtime
Open

Use chdb npm runtime for local mode#791
ShawnChen-Sirius wants to merge 1 commit into
MapleTechLabs:mainfrom
ShawnChen-Sirius:codex/maple-chdb-npm-runtime

Conversation

@ShawnChen-Sirius

@ShawnChen-Sirius ShawnChen-Sirius commented Sep 7, 2026

Copy link
Copy Markdown

Summary

This changes Maple Local's embedded chDB integration from direct Bun FFI against a sibling libchdb.so to the published chdb npm package (chdb@3.3.0). The public Maple behavior stays the same: maple start, local ingest/query, checkpoint/restore, and bundled release installs continue to work without requiring users to install Node, npm, ClickHouse, or chDB manually.

Key points:

  • Replace the internal chDB access path with chdb npm Session.
  • Preserve Maple's required chDB startup behavior through a generated config overlay, since the current npm latest Session API does not expose connection argv.
  • Keep UTC timezone pinning for the native runtime.
  • Package releases as maple + node_modules/chdb instead of maple + libchdb.so.
  • Update install/update/release scripts, docs, native probes, and tests for the new runtime sidecar.

Closes #789

Verification

  • bun --filter @maple/cli typecheck
  • bun test --max-concurrency=1 apps/cli/test/chdb-args.test.ts apps/cli/test/chdb-timezone.test.ts apps/cli/test/update.test.ts
  • bun --filter @maple/cli test — 539/539 passing
  • OUT_DIR=/private/tmp/maple-chdb-npm-bundle-01a07dd0 scripts/build-local-binary.sh
  • Compiled bundle smoke: started maple, queried /health and /local/query, confirmed timezone() = UTC and version() = 26.7.2.1

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@ShawnChen-Sirius

Copy link
Copy Markdown
Author

Compatibility note from a local fixture test:

I generated a checkpoint with Maple’s previous chdb-core v26.1.0 release asset. With the fixture left unchanged, this PR rejects it before restore:

checkpoint chDB version mismatch (checkpoint: v26.1.0; build: 26.7.2.1)

Then I changed only the fixture manifest’s chdbVersion to 26.7.2.1 and retried with the same backup bytes. Restore succeeded on 26.7.2.1, including the fresh-process reopen probe. A follow-up query also read the fixture probe row successfully.

This suggests the tested backup bytes are compatible with 26.7.2.1. For checkpoint restore, we may want to replace the strict chdbVersion equality check with an explicit compatibility allowlist or migration path, so engine upgrades do not unnecessarily block recovery.

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 7ef4c59a-8681-4203-a45f-2cffef6dad01

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Makisuo

Makisuo commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

I generally wouldn’t mind using the npm package directly, but this breaks maple update for existing installs: the old updater expects libchdb.so in the release archive, so it fails and rolls back. Updating the updater in the new binary doesn’t solve that transition.

It also adds chdb, node-addon-api, node-gyp-build, @clickhouse/client-common, and the native @chdb/lib-* package to the shipped bundle. I’m trying to keep the distribution lean and ensure it runs without Node.js or npm installed. The Bun executable should still support that, but we should verify it on a clean machine, trim any unnecessary build dependencies, and handle the existing update path before merging.

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.

Proposal: use the chdb npm package instead of direct libchdb FFI

2 participants