Repository navigation
fix: load the worker and browser entry without Node built-ins - #17
Merged
Merged
Conversation
The worker entry is documented as safe for browsers and V8 isolates, but vectoria-tfidf imported sanitizeObject from storage/serialization.utils, which imports Node's crypto at load for hash(). Every browser bundle of vectoriadb/worker (or of the root export under the browser condition) failed on "crypto", and an isolate without Node compatibility could not load it. sanitizeObject now lives in its own module with no imports; serialization.utils re-exports it, so the public API is unchanged. The package also declares tslib, which the build's importHelpers output requires but was never listed as a dependency. A new spec loads the worker entry with every Node built-in mocked to throw, and runs a TF-IDF search through it.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Contributor
Cherry-pick CreatedA cherry-pick PR to Please review and merge if this change should also be in If the cherry-pick is not needed, close the PR. |
frontegg-david
added a commit
to agentfront/frontmcp
that referenced
this pull request
Oct 5, 2026
… browser
vectoriadb was an optional peer that the SDK loaded with a literal
import('vectoriadb') on the first skill search. A browser bundle of the
SDK therefore failed with 'Could not resolve "vectoriadb"' unless the
consumer installed it (#761), and installing it did not help: in 2.3.2
its worker entry imported Node's crypto and an undeclared tslib, fixed in
vectoriadb 2.3.3 (agentfront/vectoriadb#17).
vectoriadb (^2.3.3) is now a regular dependency. The SDK imports its
worker-safe entry, vectoriadb/worker: the TF-IDF/BM25 index the skill
search uses, with no dependencies beyond tslib and no Node built-ins. The
index is still created on the first search; the optional-peer loading
and the spec that pinned it are gone. The browser-bundle e2e app runs a
skill search in Chromium, and the skills, testing and create-skill pages
no longer call vectoriadb an optional peer.
frontegg-david
added a commit
to agentfront/frontmcp
that referenced
this pull request
Oct 5, 2026
… build (#762) * fix(sdk): build connect() clients without an HTTP host connect() (and connectOpenAI() / connectClaude()) builds its server through FrontMcpInstance.createForGraph(), which still selected the Express-backed server provider. #748 made createDirect() and createFetchHandler() pass serve: false; createForGraph() did not, so in the browser build connect() failed with "ExpressHostAdapter is not available in browser environments" (#761). It never listens, so it now passes serve: false too. createEdgeMcp() already passed it. * fix(sdk): start ConfigPlugin in the browser build loadConfig() and loadEnvFiles() resolved .env, .env.local and config.yml with pathResolve() from @frontmcp/utils, whose browser build throws, so every ConfigPlugin failed at startup in a browser (#761). Where the runtime context is the browser build, the file sources now count as absent, and process.env is read only where it exists, so the config comes from the schema defaults and process.env. The browser-bundle e2e app runs connect() and a ConfigPlugin server in Chromium. Its other result checks now wait for the page summary, as the first ones do, instead of reading the results before the async checks finish. The browser compatibility, config and build-for-browser pages describe both entry points and the 'browser' runtime value. * fix(sdk): make vectoriadb a dependency and bundle skill search in the browser vectoriadb was an optional peer that the SDK loaded with a literal import('vectoriadb') on the first skill search. A browser bundle of the SDK therefore failed with 'Could not resolve "vectoriadb"' unless the consumer installed it (#761), and installing it did not help: in 2.3.2 its worker entry imported Node's crypto and an undeclared tslib, fixed in vectoriadb 2.3.3 (agentfront/vectoriadb#17). vectoriadb (^2.3.3) is now a regular dependency. The SDK imports its worker-safe entry, vectoriadb/worker: the TF-IDF/BM25 index the skill search uses, with no dependencies beyond tslib and no Node built-ins. The index is still created on the first search; the optional-peer loading and the spec that pinned it are gone. The browser-bundle e2e app runs a skill search in Chromium, and the skills, testing and create-skill pages no longer call vectoriadb an optional peer. * fix(sdk): import vectoriadb from its package root The subpath vectoriadb/worker exists only in the package's exports map, which moduleResolution "node" ignores. tsconfig.base.json uses it, so the webpack builds that compile the SDK source, such as apps/demo, failed with TS2307 "Cannot find module 'vectoriadb/worker'". The SDK imports the package root instead. Its types resolve through the package's types field under any resolution mode, and its exports map lists the worker and browser conditions before import, so browser and worker bundles still get the TF-IDF entry without Node built-ins; Node gets the full entry. A browser bundle of the SDK includes only vectoriadb's worker.js, vectoria-tfidf.js, tfidf.embedding.service.js and sanitize.utils.js.
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.
Problem
vectoriadb/worker, and the root export under thebrowser/workerconditions, is documented as safe to bundle for browsers and V8 isolates. As published in 2.3.2 it isn't:crypto:vectoria-tfidf.tsimportssanitizeObjectfromstorage/serialization.utils.ts, and that file imports Node'scryptoat load forhash(). esbuild withplatform: browserfails withCould not resolve "crypto". An isolate without Node compatibility can't load the entry at all.tslib: the build runs withimportHelpers: true, so the output callsrequire("tslib"), but the package doesn't declaretslib. A clean install fails withCould not resolve "tslib".FrontMCP found this while making
vectoriadba regular dependency of@frontmcp/sdkfor skill search in the browser (agentfront/frontmcp#761, #762). With 2.3.2, the SDK's browser bundle failed at load oncrypto.Fix
sanitizeObjectmoves tosrc/sanitize.utils.ts, which has no imports.storage/serialization.utils.tsre-exports it, soimport { sanitizeObject } from 'vectoriadb'and the existing importers are unchanged.vectoria-tfidf.tsimports it from the new module.tslib:libs/vectoriadb/package.jsondeclares it (^2.8.1, the version the workspace already uses).Verification
worker-entry.spec.tsloads../workerwithcrypto,fs,fs/promises,path,os,child_process,netandstreammocked to throw, then runs a TF-IDF search through it. Onrelease/2.3.xit fails withthe worker entry required the Node built-in "crypto".nx test vectoriadbpasses 12 suites, 378 tests.import { TFIDFVectoria } from 'vectoriadb/worker'with esbuild (--platform=browser, no externals, notslibinstalled). It bundles and searches correctly. On 2.3.2 the same bundle fails ontslib, then oncrypto.worker.js,vectoria-tfidf.js,sanitize.utils.jsandtfidf.embedding.service.jsrequire only each other.Publishing this as 2.3.3 unblocks the vectoriadb part of agentfront/frontmcp#762.