fix(openclaw): normalize better-sqlite3 bootstrap paths on Windows#1203
Open
fancyboi999 wants to merge 2 commits intoMemTensor:mainfrom
Open
fix(openclaw): normalize better-sqlite3 bootstrap paths on Windows#1203fancyboi999 wants to merge 2 commits intoMemTensor:mainfrom
fancyboi999 wants to merge 2 commits intoMemTensor:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a Windows-specific false negative when checking whether better-sqlite3 resolved within the OpenClaw plugin directory by normalizing path handling and refactoring the bootstrap logic into a testable helper.
Changes:
- Extracted
better-sqlite3bootstrap/load/rebuild logic intosrc/runtime/sqlite-bootstrap.ts. - Replaced string-prefix path checks with a
path.relative(...)-based containment check. - Added unit tests covering Windows path normalization and rebuild retry behavior; updated plugin entry to use the new helper.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| apps/memos-local-openclaw/tests/sqlite-bootstrap.test.ts | Adds unit tests for Windows path conversion, containment checks, and rebuild retry logic. |
| apps/memos-local-openclaw/src/runtime/sqlite-bootstrap.ts | Introduces a reusable/bootstrap helper for resolving/loading/rebuilding better-sqlite3 with improved path containment logic. |
| apps/memos-local-openclaw/index.ts | Switches the plugin entrypoint to use the new bootstrap helper and reads package.json relative to the resolved plugin dir. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This fixes the Windows false negative in the OpenClaw plugin bootstrap for
better-sqlite3.Problem solved:
new URL(import.meta.url).pathnameand a rawstartsWithcheck to decide whetherbetter-sqlite3resolved inside the plugin directory.pathnamecan produce/C:/...whilerequire.resolve(...)returnsC:/..., so the same path is incorrectly treated as outside the plugin dir.better-sqlite3 native module not foundeven when the module is already installed.Implementation approach:
import.meta.urlto a real filesystem path withfileURLToPath(..., { windows: true })on Windows.path.relative(...).package.json, removing the previous dependency on__dirnamesemantics.Related Issue (Required): Fixes #1192
Type of change
How Has This Been Tested?
Commands run locally:
cd apps/memos-local-openclaw && npx vitest run tests/sqlite-bootstrap.test.ts tests/shutdown-lifecycle.test.ts --reporter=dotcd apps/memos-local-openclaw && npm run buildCoverage added in this PR:
import.meta.urlto filesystem path conversionNotes:
tests/plugin-impl-access.test.tsshowed an existing local runner-exit hang when run standalone in this environment. This PR does not changeplugin-impl.ts, and the new bootstrap tests cover the runtime path logic introduced here.Checklist