-
Notifications
You must be signed in to change notification settings - Fork 132
chore: add debug scripts #3467
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?
chore: add debug scripts #3467
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. |
PR Review: Add Debug ScriptsSummaryThis PR adds debugging utilities to help visualize and analyze Rivet engine logs. The main additions are:
Code Quality & Best PracticesPositive Aspects
Issues & Suggestions1. Potential bugs in logfmt_to_gantt.tsLine 505, 508, 513: Potential runtime error when const wfId = task.metadata.workflow_id.substring(0, 8); // Could crash if undefinedThe code assumes const wfId = task.metadata.workflow_id?.substring(0, 8) || 'unknown';Line 225: No validation that const startTime = entries[0].ts;While there's a check at line 171, subsequent filtering (lines 177-208) could leave the array empty. The empty check at line 204 should be moved after the time filtering logic. 2. Logic issuesLines 188-191, 194-199: Inefficient array mutation entries.splice(0, entries.length, ...entries.filter(...));This creates a copy of the filtered array and splices it back. Better to use simple reassignment: const filtered = entries.filter(...);
entries.length = 0;
entries.push(...filtered);Or better yet, avoid mutation entirely and use a new variable. Lines 317-323: Operation matching logic is fragile for (const [k, task] of operationTasks.entries()) {
if (k.startsWith(entry.operation_name) && !task.end) {
task.end = entry.ts;
break;
}
}This matches by string prefix, which could incorrectly match operations with similar names (e.g., "operation" would match "operation_call"). Should use exact name matching with timestamp-based pairing. 3. Error handlingMissing error handling for:
Recommended pattern: try {
const content = readFileSync(inputFile, 'utf-8');
} catch (error) {
console.error(`Failed to read file ${inputFile}:`, error.message);
process.exit(1);
}4. Performance considerationsLine 317-323: Nested loop for operation matching - O(n²) complexity if many operations Line 188-199: Creating new arrays for filtering when could filter once and store result 5. Code style issuesHard-coded file paths: Lines 11, 145, 146 use
Magic numbers:
Inconsistent string concatenation: Mix of template literals and string concatenation Security ConcernsLow Risk Issues
Performance Considerations
Test CoverageMissing tests: No tests are included for these utilities. Recommended test cases:
Additional ObservationsPositive
Minor improvements
Overall AssessmentRecommendation: Approve with minor fixes These are useful debugging tools that will help with development and troubleshooting. The code is generally well-written but has some potential runtime errors that should be fixed before merging: Must fix:
Should fix:
Nice to have:
|
13210ec to
eb75b3a
Compare
Code ReviewThank you for adding these debug utilities! These tools will be valuable for debugging and analyzing Rivet engine execution. Positives
Code Quality Issues1. Potential null pointer exception (logfmt_to_gantt.ts:505, 508) 2. Inconsistent array mutation (logfmt_to_gantt.ts:188, 194) 3. Non-unique task keys (logfmt_to_gantt.ts:303) 4. Inefficient operation matching (logfmt_to_gantt.ts:317-323) Performance Considerations
Best Practices
Recommendations
Summary: Useful debugging tools with clean structure. Main concerns are null safety (critical) and large file handling. Recommend approval with suggested improvements for null safety. |

No description provided.