-
Notifications
You must be signed in to change notification settings - Fork 135
fix(runner-protocol): do not depend on node:assert for generated code #3521
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: main
Are you sure you want to change the base?
fix(runner-protocol): do not depend on node:assert for generated code #3521
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
How to use the Graphite Merge QueueAdd the label merge-queue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Code ReviewSummaryThis PR removes the dependency on Node.js's Positive Aspects ✅
Issues and Concerns 🔍1. String Replacement Fragility (Medium Priority)let content = content.replace("import assert from \"node:assert\"\n", "");Issue: This exact string match is brittle and could fail if:
Suggestion: Use a regex pattern for more robust matching: use regex::Regex;
let assert_import_regex = Regex::new(r#"import\s+assert\s+from\s+['\"]node:assert['\"];?\s*\n?"\#)
.expect("Failed to compile regex");
let content = assert_import_regex.replace(&content, "").to_string();2. Formatting Issue (Low Priority)let content = format\!("{}\n{}", content, assert_function);This adds an extra blank line between the last generated code and the assert function. Consider: let content = format\!("{}{}", content, assert_function);The assert_function raw string already includes a leading \n. 3. Missing Error Context (Low Priority)The panics in fs::read_to_string(file_path)
.unwrap_or_else(|e| panic\!("Failed to read generated TypeScript file at {}: {}", file_path.display(), e))
fs::write(file_path, content)
.unwrap_or_else(|e| panic\!("Failed to write post-processed TypeScript file at {}: {}", file_path.display(), e))4. Verification (Medium Priority)Consider verifying that the replacement actually occurred: if content.contains("node:assert") {
eprintln\!(
"cargo:warning=Failed to remove node:assert import from {}. Manual review required.",
file_path.display()
);
}5. TypeScript Type Safety (Low Priority)The custom assert function is well-typed with the /**
* Asserts that a condition is true, throwing an error if false.
* @param condition - The condition to assert
* @param message - Optional error message
* @throws {Error} If condition is false
*/
function assert(condition: boolean, message?: string): asserts condition {
if (\!condition) throw new Error(message ?? "Assertion failed")
}Testing Recommendations 🧪This PR appears to lack test coverage. Consider adding:
Example test structure: cd engine/sdks/typescript/runner-protocol
pnpm run build && pnpm run check-typesSecurity Considerations 🔒No security concerns identified. The change is purely about dependency management and doesn't introduce attack vectors. Performance Considerations ⚡
RecommendationsBefore Merge:
Future Improvements:
Verdict✅ Approve with minor suggestions The core change is sound and solves a real portability issue. The suggestions above are mostly about making the solution more robust and maintainable. The PR is safe to merge after verifying the build works correctly. Review generated by Claude Code |
More templates
@rivetkit/cloudflare-workers
@rivetkit/db
@rivetkit/framework-base
@rivetkit/next-js
@rivetkit/react
rivetkit
@rivetkit/sql-loader
@rivetkit/engine-runner
@rivetkit/engine-runner-protocol
commit: |

No description provided.