-
Notifications
You must be signed in to change notification settings - Fork 131
chore(rivetkit-typescript): remove dependency on node modules #3460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 11-10-feat_site_add_typedoc_docs
Are you sure you want to change the base?
chore(rivetkit-typescript): remove dependency on node modules #3460
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
PR Review: chore(rivetkit-typescript): remove dependency on node modulesOverviewThis PR refactors the RivetKit TypeScript package to use dynamic imports for Node.js modules instead of static imports, enabling better compatibility with non-Node.js environments (like edge runtimes). The approach centralizes all Node.js module access through a new Strengths ✅
Issues Found 🔴1. Critical: Potential Race Condition in Global StateIn constructor(persist: boolean = true, customPath?: string) {
this.#persist = persist;
this.#storagePath = persist ? getStoragePath(customPath) : "/tmp";
const path = getNodePath(); // ⚠️ Called in constructor
this.#stateDir = path.join(this.#storagePath, "state");
// ...
}However, in export async function createFileSystemOrMemoryDriver(...) {
// Import Node.js dependencies before creating the state
await importNodeDependencies();
const state = new FileSystemGlobalState(persist, customPath); // ⚠️ Constructor runs AFTER import
}Problem: The Solution: Ensure 2. Inconsistent Error MessageIn console.warn(
"Node.js modules not available, file system driver will not work",
err,
);Recommendation: Use the structured logging pattern from CLAUDE.md. Should be: logger().warn({ err, msg: "node.js modules not available, file system driver will not work" });However, this creates a circular dependency since logging might need to be set up first. Consider whether this error case should be silent (just throw) or use a different approach. 3. Missing Type Safety in Runner ProtocolIn function assert(condition: boolean, message?: string): asserts condition {
if (!condition) throw new Error(message ?? "Assertion failed")
}This is technically correct, but the implementation could be more robust. The original Minor issue: Not critical, but worth noting the behavioral difference. 4. Breaking Change Not DocumentedThe change from synchronous to asynchronous driver creation ( // Before (synchronous)
const driver = createFileSystemDriver();
// After (async - REQUIRED)
const driver = await createFileSystemDriver();Recommendation:
Potential Concerns
|

No description provided.