fix(rivetkit): add config parameters to spawned serverless engine for local dev#3994
Conversation
|
🚅 Deployed to the rivet-pr-3994 environment in rivet-frontend
|
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. |
Pull Request Review: fix(rivetkit): add config parameters to spawned serverless engine for local devThis PR improves the local development experience by adding development-optimized configuration parameters and better error diagnostics for the spawned serverless engine. ✅ Positive Changes1. Development-Optimized Timeouts (lines 99-121)
2. Enhanced Error Detection (lines 132-179)
3. Structured Logging 🔍 Potential Issues1. Memory Leak Risk (lines 133-137) const stderrChunks: Buffer[] = [];
if (child.stderr) {
child.stderr.on("data", (chunk: Buffer) => {
stderrChunks.push(chunk);
});Issue: If the engine process runs for an extended period and produces significant stderr output, the Recommendation: Consider one of these approaches:
Example fix: const MAX_STDERR_BYTES = 1024 * 100; // 100KB limit
let stderrSize = 0;
const stderrChunks: Buffer[] = [];
if (child.stderr) {
child.stderr.on("data", (chunk: Buffer) => {
if (stderrSize < MAX_STDERR_BYTES) {
stderrChunks.push(chunk);
stderrSize += chunk.length;
}
});
child.stderr.pipe(stderrStream);
}2. Error Detection Timing (line 147) child.once("exit", (code, signal) => {
const stderrOutput = Buffer.concat(stderrChunks).toString("utf-8");Issue: The error detection only happens on process exit. If the engine crashes immediately on startup due to these specific errors, this works well. However, if the process hangs or exits later, the developer won't see these helpful messages until much later. Recommendation: Consider checking for these error patterns earlier during the 3. Configuration Values Hard-coded (lines 109-120) Issue: The timeout and threshold values are hard-coded as strings. While appropriate for development, there's no validation or documentation of what the "production" defaults are. Recommendation:
Example: // Production default: 30000ms, reduced to 100ms for dev
RIVET__PEGBOARD__RETRY_RESET_DURATION: "100",🤔 Questions & Suggestions1. Unit Values Inconsistency
Could you clarify if these are all milliseconds or if there's a unit mismatch? The comment on line 118 suggests seconds, but "1" seems extremely short for a shutdown duration. 2. Error Message Consistency
The first message uses lowercase and says "internal error", while this is actually a user-recoverable condition with helpful guidance. Consider rephrasing to be more consistent with the helpful tone of the second message. 3. Test Coverage
📊 SummaryCode Quality: ✅ Good - follows project conventions, well-commented Recommended Actions
Overall, this is a valuable improvement to the developer experience. The main concern is the unbounded buffer growth which should be addressed before merging. |
fe728ec to
65ef05a
Compare
63adbe3 to
fcd3d15
Compare
More templates
@rivetkit/cloudflare-workers
@rivetkit/db
@rivetkit/framework-base
@rivetkit/next-js
@rivetkit/react
rivetkit
@rivetkit/sql-loader
@rivetkit/virtual-websocket
@rivetkit/engine-runner
@rivetkit/engine-runner-protocol
commit: |
fcd3d15 to
47530e5
Compare
Merge activity
|

No description provided.