fix(ckb-debugger): lazy-load WASI module to suppress ExperimentalWarning#407
Merged
fix(ckb-debugger): lazy-load WASI module to suppress ExperimentalWarning#407
Conversation
Convert static import of node:wasi to dynamic import with caching. This prevents the ExperimentalWarning from being emitted when running non-debugger commands like 'offckb accounts' or 'offckb config list'. The WASI module is now only loaded when debugger functionality is actually executed. Fixes #405
|
✅ Changeset file detected. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses CLI noise by preventing node:wasi from being loaded during startup for non-debugger commands, eliminating the WASI ExperimentalWarning unless the WASM debugger is actually executed.
Changes:
- Replaced the static
node:wasiimport with a cached dynamic import insideCkbDebuggerWasi. - Updated the WASI host instantiation to use the lazily loaded module.
- Added a changeset documenting the patch release.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/tools/ckb-debugger-wasm.ts |
Lazy-loads node:wasi via a cached dynamic import and updates WASI host creation accordingly. |
.changeset/lazy-wasi-warning.md |
Adds a patch changeset describing the warning suppression fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try { | ||
| CkbDebuggerWasi.wasiModule = await import('node:wasi'); | ||
| } catch (error) { | ||
| throw new Error('Failed to load WASI module. Node.js >= 20.0.0 is required for WASM debugger support.'); |
f585d2b to
584a685
Compare
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.
Summary
Fixes #405 - Non-debugger commands emit WASI ExperimentalWarning
Problem
The static import `import * as wasi from 'node:wasi'` in `src/tools/ckb-debugger-wasm.ts` was causing the WASI module to load at CLI startup, even for commands that don't use the debugger (like `offckb accounts` or `offckb config list`). This resulted in the unwanted warning:
```
(node:xxxx) ExperimentalWarning: WASI is an experimental feature and might change at any time
```
Solution
Convert the static import to a dynamic import with caching:
The WASI module is now only loaded when debugger functionality is actually executed.
Changes
Verification
Tested the following commands:
Type Safety
The implementation maintains proper TypeScript typing using `typeof import('node:wasi')` for the dynamic import cache.