fix: lazy-load SqliteProvider to avoid node:sqlite ExperimentalWarning#16
Open
robertsLando wants to merge 1 commit intoplatformatic:mainfrom
Open
fix: lazy-load SqliteProvider to avoid node:sqlite ExperimentalWarning#16robertsLando wants to merge 1 commit intoplatformatic:mainfrom
robertsLando wants to merge 1 commit intoplatformatic:mainfrom
Conversation
Eagerly requiring ./lib/providers/sqlite.js pulled in node:sqlite at module load time, emitting `ExperimentalWarning: SQLite is an experimental feature` for every consumer — even those who only use MemoryProvider or RealFSProvider. The warning was especially noisy in SEA/pkg binaries where vfs is loaded unconditionally. Expose SqliteProvider via a lazy getter on module.exports. The first access resolves the module and memoizes the value, so behavior and API shape are preserved; node:sqlite (and its warning) is only loaded when a consumer actually touches vfs.SqliteProvider.
3 tasks
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
SqliteProvidera lazy getter onmodule.exportssonode:sqliteis only required when a consumer actually readsvfs.SqliteProvider.ExperimentalWarning: SQLite is an experimental featurethat was emitted on everyrequire('@platformatic/vfs'), even for consumers that only useMemoryProvider/RealFSProvider.Why
index.jseagerly required./lib/providers/sqlite.js, which in turn importsnode:sqliteat the top of the module.node:sqliteemits anExperimentalWarningthe first time it is loaded in a process. That meant:@platformatic/vfsprinted the warning on startup, regardless of whether SQLite was used.pkgbinaries where@platformatic/vfsis loaded unconditionally during bootstrap.The alternative fixes were weaker:
pkg'ssea-bootstrap.js) hides it but keeps the eager load — users still pay thenode:sqlitestartup cost, and non-SEA consumers still see the warning.@platformatic/vfs/sqlite) is cleaner long-term but a breaking API change.The lazy getter is zero API break: the export shape (
typeof vfs.SqliteProvider === 'function', enumerable on the object) is preserved, and the value is memoized on first access.Test plan
node --test test/sqlite.test.js— all 90 sqlite tests pass.require('./index.js')without touchingSqliteProvider→ noExperimentalWarning.vfs.SqliteProvider→ warning fires exactly once, as expected.eslint index.jsclean.