fix tauri build issue - #2169
Conversation
WalkthroughAdds macOS bundling for Changes
Sequence Diagram(s)sequenceDiagram
participant Dev as Developer CLI
participant BuildJS as packages/orderbook/scripts/build.js
participant BuildPkg as packages/orderbook/scripts/buildPackage.js
participant Generator as ESM/CJS emitter
Dev->>BuildJS: run build [isTauriBuild?]
BuildJS->>BuildPkg: node buildPackage <package> <isTauriBuild?>
alt isTauriBuild = true
BuildPkg->>Generator: emit CJS/ESM with Buffer + embedded wasm blob + initSync(bytes)
else isTauriBuild = false
BuildPkg->>Generator: emit standard async __wbg_init(bytes) init code
end
BuildPkg-->>Dev: generated artifacts
sequenceDiagram
participant Nix as flake.nix
participant FS as Filesystem
participant Tools as install_name_tool / otool
participant App as macOS app bundle
Nix->>FS: copy libbz2.1.dylib -> app/lib/
FS->>Tools: set dylib id (install-name)
Tools->>App: run install_name_tool -change on dependent binaries -> bundled dylib
Tools->>Nix: run otool to verify references
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (1)📚 Learning: 2025-09-06T07:12:25.751ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
flake.nix (1)
196-208: Handle both libbz2 install-name variants and broaden the no-/nix/store check.Some derivations expose libbz2.1.0.dylib; add a fallback -change for that case. Also consider scanning all vendored dylibs, not only the main binary.
- install_name_tool -change ${pkgs.bzip2.out}/lib/libbz2.1.dylib @executable_path/../Frameworks/libbz2.1.dylib src-tauri/target/release/Raindex + install_name_tool -change ${pkgs.bzip2.out}/lib/libbz2.1.dylib @executable_path/../Frameworks/libbz2.1.dylib src-tauri/target/release/Raindex + if otool -L src-tauri/target/release/Raindex | grep -q '${pkgs.bzip2.out}/lib/libbz2.1.0.dylib'; then + install_name_tool -change ${pkgs.bzip2.out}/lib/libbz2.1.0.dylib @executable_path/../Frameworks/libbz2.1.dylib src-tauri/target/release/Raindex + fiOptionally replace the single-binary grep with this snippet to cover all artifacts:
# Fail on any /nix/store reference across the app exe and vendored dylibs otool -L src-tauri/target/release/Raindex for t in src-tauri/target/release/Raindex lib/*.dylib; do otool -L "$t" | grep -q '/nix/store' && { echo "Build guard: $t references /nix/store"; exit 1; } done
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
flake.nix(2 hunks)tauri-app/src-tauri/tauri.conf.json(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: brusherru
PR: rainlanguage/rain.orderbook#2044
File: tauri-app/src/routes/orders/[chainId]-[orderbook]-[orderHash]/+page.svelte:76-78
Timestamp: 2025-07-31T19:03:56.594Z
Learning: In the rainlanguage/rain.orderbook project, when the Tauri app has issues preventing proper testing, the team prefers to defer Tauri-specific implementations to separate PRs rather than including untested code, especially for financial operations like withdrawals.
📚 Learning: 2025-05-14T17:13:13.878Z
Learnt from: 0xgleb
PR: rainlanguage/rain.orderbook#1776
File: tauri-app/src-tauri/tauri.conf.json:56-59
Timestamp: 2025-05-14T17:13:13.878Z
Learning: Tauri configuration (tauri.conf.json) does not support environment variable interpolation in framework paths for macOS. Using syntax like ${VAR}/lib.dylib will result in a literal "Library not found" error with that exact string.
Applied to files:
tauri-app/src-tauri/tauri.conf.json
📚 Learning: 2025-05-14T17:13:13.878Z
Learnt from: 0xgleb
PR: rainlanguage/rain.orderbook#1776
File: tauri-app/src-tauri/tauri.conf.json:56-59
Timestamp: 2025-05-14T17:13:13.878Z
Learning: Tauri configuration (tauri.conf.json) does not support environment variable interpolation in framework paths. Using syntax like ${VAR}/lib.dylib will result in a literal "Library not found" error with that exact string.
Applied to files:
tauri-app/src-tauri/tauri.conf.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (17)
- GitHub Check: test
- GitHub Check: build-tauri (ubuntu-22.04, true)
- GitHub Check: test
- GitHub Check: standard-tests (ubuntu-latest, rainix-rs-artifacts, true)
- GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-test)
- GitHub Check: standard-tests (ubuntu-latest, rainix-sol-static)
- GitHub Check: standard-tests (ubuntu-latest, rainix-sol-test)
- GitHub Check: standard-tests (ubuntu-latest, test-js-bindings)
- GitHub Check: standard-tests (ubuntu-latest, rainix-sol-legal)
- GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-artifacts)
- GitHub Check: standard-tests (ubuntu-latest, rainix-rs-static)
- GitHub Check: standard-tests (ubuntu-latest, ob-rs-test, true)
- GitHub Check: standard-tests (ubuntu-latest, rainix-sol-artifacts)
- GitHub Check: git-clean
- GitHub Check: test
- GitHub Check: Deploy-Preview-Push
- GitHub Check: Deploy-Docs-Preview
🔇 Additional comments (1)
tauri-app/src-tauri/tauri.conf.json (1)
59-61: macOS frameworks: addition looks correct and matches build script outputs.The relative paths resolve to tauri-app/lib during Tauri’s hooks and avoid env-var interpolation pitfalls. Looks good. Based on learnings.
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (5)
packages/orderbook/package.json(1 hunks)packages/orderbook/scripts/build.js(2 hunks)packages/orderbook/scripts/buildPackage.js(2 hunks)packages/webapp/package.json(1 hunks)tauri-app/package.json(1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2025-09-06T07:12:25.751Z
Learnt from: CR
PR: rainlanguage/rain.orderbook#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-06T07:12:25.751Z
Learning: Applies to packages/webapp/**/*.{svelte,ts,js} : Webapp: build with `npm run build -w rainlanguage/webapp`
Applied to files:
packages/webapp/package.jsontauri-app/package.json
📚 Learning: 2025-09-06T07:12:25.751Z
Learnt from: CR
PR: rainlanguage/rain.orderbook#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-06T07:12:25.751Z
Learning: Applies to packages/webapp/**/*.{svelte,ts,js} : Webapp: run tests with `npm run test -w rainlanguage/webapp`
Applied to files:
packages/webapp/package.json
📚 Learning: 2025-09-06T07:12:25.751Z
Learnt from: CR
PR: rainlanguage/rain.orderbook#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-06T07:12:25.751Z
Learning: Applies to packages/ui-components/**/*.{svelte,ts,js} : UI components: build with `npm run build -w rainlanguage/ui-components`
Applied to files:
packages/webapp/package.jsontauri-app/package.json
📚 Learning: 2025-09-06T07:12:25.751Z
Learnt from: CR
PR: rainlanguage/rain.orderbook#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-06T07:12:25.751Z
Learning: Applies to packages/orderbook/**/*.{ts,tsx} : Orderbook package: build with `npm run build:orderbook`
Applied to files:
packages/orderbook/package.json
🪛 Biome (2.1.2)
packages/orderbook/scripts/build.js
[error] 27-27: Illegal use of reserved keyword package as an identifier in strict mode
(parse)
packages/orderbook/scripts/buildPackage.js
[error] 5-5: Illegal use of reserved keyword package as an identifier in strict mode
(parse)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (17)
- GitHub Check: test
- GitHub Check: standard-tests (ubuntu-latest, ob-rs-test, true)
- GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-test)
- GitHub Check: standard-tests (ubuntu-latest, rainix-sol-legal)
- GitHub Check: standard-tests (ubuntu-latest, rainix-sol-test)
- GitHub Check: standard-tests (ubuntu-latest, rainix-rs-static)
- GitHub Check: standard-tests (ubuntu-latest, rainix-sol-artifacts)
- GitHub Check: standard-tests (ubuntu-latest, rainix-rs-artifacts, true)
- GitHub Check: standard-tests (ubuntu-latest, test-js-bindings)
- GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-artifacts)
- GitHub Check: standard-tests (ubuntu-latest, rainix-sol-static)
- GitHub Check: test
- GitHub Check: build-tauri (ubuntu-22.04, true)
- GitHub Check: test
- GitHub Check: git-clean
- GitHub Check: Deploy-Docs-Preview
- GitHub Check: Deploy-Preview-Push
🔇 Additional comments (5)
packages/orderbook/package.json (1)
35-35: LGTM! Clean integration of Tauri build path.The new script properly mirrors the existing build workflow while passing the Tauri flag to enable conditional build logic downstream.
tauri-app/package.json (1)
8-9: LGTM! Proper build orchestration for Tauri.The scripts correctly ensure the orderbook package is built in Tauri mode before proceeding with dev or build workflows.
packages/orderbook/scripts/build.js (1)
4-5: LGTM! Flag handling is correct.The truthy string "tauri" passed from the build-tauri script will properly evaluate in the conditional at line 27.
packages/webapp/package.json (1)
9-10: LGTM! Correct build dependency for webapp.The webapp appropriately uses the regular build (not build-tauri), as it's a web-only package. The Tauri-specific build is correctly isolated to tauri-app.
packages/orderbook/scripts/buildPackage.js (1)
78-87: Top-level await requires modern module support.The non-Tauri path uses
await __wbg_init(bytes)at the top level (line 85). This requires:
"type": "module"in package.json (confirmed in packages/orderbook/package.json, though not visible in this PR)- Modern Node.js (≥14.8.0) or browser environment with ES module support
Since package.json specifies
"engines": { "node": ">=22" }, this is safe. However, consider wrapping in error handling:-import { Buffer } from 'buffer'; -import wasmB64 from '../esm/orderbook_wbg.json'; -const bytes = Buffer.from(wasmB64.wasm, 'base64'); -await __wbg_init(bytes);` +import { Buffer } from 'buffer'; +import wasmB64 from '../esm/orderbook_wbg.json'; +const bytes = Buffer.from(wasmB64.wasm, 'base64'); +try { + await __wbg_init(bytes); +} catch (err) { + console.error('Failed to initialize WASM:', err); + throw err; +}`Similar error handling should be added to the Tauri path.
|
@coderabbitai assess this PR size classification for the totality of the PR with the following criterias and report it in your comment: S/M/L PR Classification Guidelines:This guide helps classify merged pull requests by effort and complexity rather than just line count. The goal is to assess the difficulty and scope of changes after they have been completed. Small (S)Characteristics:
Review Effort: Would have taken 5-10 minutes Examples:
Medium (M)Characteristics:
Review Effort: Would have taken 15-30 minutes Examples:
Large (L)Characteristics:
Review Effort: Would have taken 45+ minutes Examples:
Additional Factors to ConsiderWhen deciding between sizes, also consider:
Notes:
|
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 154 🏁 Script executed: Length of output: 46 SIZE=L 🧠 Learnings used |
@CodeRabbit how did you come up with L for the size? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 494 🏁 Script executed: Length of output: 4878 @rouzwelt, you're absolutely right to question that! I made an error in my initial size assessment. Let me provide the correct statistics: Based on the PR data from GitHub:
The correct size should be SIZE=S (Small), not L. PRs with 10-49 total line changes are classified as Small. I apologize for the confusion in my initial response. Here's the proper size report: TOTAL=46 Oops, my bad! Got my carrots mixed up there. 🧠 Learnings used |
Motivation
This PR fixes the tauri build issue and tauri white screen issue
Solution
Due to rainix updates (probably), a new lib was pointing to nix store and causing the bundle script to fail upon check for files to not point to nix store, so need to include that lib in the bundle and build scripts
white screen issue is caused by race condition due to WebKit not being able to handle top level await correctly that is used by generated wasm bindings, so we need to use sync wasm init for tauri builds, for more info about this: Top-level await support tauri-apps/tauri#9795
Checks
By submitting this for review, I'm confirming I've done the following:
Summary by CodeRabbit
New Features
Bug Fixes
Chores
Other