Conversation
Adds the core implementation for DRR including spooler, tracer, and replay utilities.
Hooks into middleware compose, request context, and body parser to tee chunks and trace execution for DRR.
Provides a CLI to replay crash snapshots against the server. Updates build config and demo app.
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.
High-Level Overview
This PR introduces Deterministic Request Replay (DRR), a native zero-overhead request snapshotting and forensic debugging ecosystem for Volten. When enabled, DRR buffers incoming request payloads and captures full request metadata upon unhandled application crashes or exceptions. Snapshots are stored in a compact, compressed binary format (
.vltn) that can be deterministically replayed against a target application instance for local debugging, automated regression testing, or forensic analysis.The feature includes a hybrid in-memory/disk-spooling engine (
HybridSpooler) to handle large body payloads without exploding memory usage, a middleware tracing framework (tracer.ts) for state-mutation diffing across middleware execution, and a dedicated CLI tool (volten drr) with terminal rendering for forensic inspection of crash snapshots.Key Technical Changes
Core Engine Integration & Plugin Hooking (
src/core/server.ts,src/utils/requestCtx.ts,src/utils/bodyParser.ts):enableDrr()toAppto attach aDRRPlugininstance and handle user-defined snapshot configurations.App.prototype.handleErrorto invokedrrEngine.onCrash()when unhandled errors bubble up.drrEngine.tee()calls inside stream collectors (parseBody,parseMultipartStream) to capture incoming body buffer chunks non-intrusively during normal request processing.drrEngine.onReset()inRequestContext.reset()to recycle and clean up spooler resources when contexts return to object pools.Hybrid Spooler & Snapshot Compression (
src/tools/drr/spooler.ts,src/tools/drr/index.ts):HybridSpoolerusing a 64KB in-memory fast path; automatically spills over to OS temporary files (0o600permissions on non-Windows) if body payload exceeds 64KB up tomaxBodySize..vltnsnapshot files ([4-byte big-endian metadata length][JSON metadata][payload body]).HybridSpooler.sweep()) to prune orphaned temporary spool files older than 1 hour.Replay Engine & Middleware Tracing (
src/tools/drr/replay.ts,src/tools/drr/tracer.ts,src/core/compose.ts):replaySnapshot()which decompresses.vltnfiles, reconstructs mock NodeIncomingMessageandServerResponsestreams, setsprocess.env.VOLTEN_DRR_REPLAY = "1", and re-dispatches throughApp.handleRequest.traceMiddleware()incompose.ts(evaluated whenVOLTEN_DRR_REPLAY === "1") to record middleware execution durations, caught errors, and context state mutation diffs (diffState()).Forensic CLI Tooling (
src/cli/index.ts,src/cli/renderer.ts,src/app.ts):volten drr replay <file.vltn>andvolten drr inspect <file.vltn>to display interactive terminal UI output including state mutations, timeline graphs, and stack traces.Build & Test Suite (
tsup.config.ts,tests/tools/drr.test.ts,tests/cli/drr-forensic.test.ts):src/tools/drr/index.tsandsrc/tools/drr/replay.ts.beforeSnapshot,onSnapshot), replay tracing, and CLI rendering.Breaking Changes
None.