rea-analysis-optimization
MOmorluto/rea490k8,444 new stars in the last 7 days
Help users and AI agents send an HTTP request that a mirrord session already received to the local application again with the `mirrord replay` CLI, instead of triggering it through the cluster again. Use when a user iterates on a handler that sits behind other services, debugs a failing request on a breakpoint, asks to replay, resend or retry a request, or when you need to check a code change against a request the session already received.
Help users and agents re-run a request against local code without producing it again. A mirrord session keeps the HTTP requests it received for the local application. mirrord replay lists them and sends one of them to the local application again, straight from mirrord. The client that made the original request is not involved.
This closes the loop for a code change: trigger the request once, then after each edit replay it and read the response.
Trigger on questions like:
mirrord replay?"As an agent, also use it on your own when a mirrord session is running and you changed a handler: replay a request the session already received instead of asking the user for a new one. The rule under Security says which requests you may replay without asking.
GET or HEAD request without asking. Before the first replay of a request with any other method, such as POST, PUT, PATCH or DELETE, ask the user, unless the user asked for that replay. Once the user agreed, you can replay that same request again.mirrord replay prints the values of headers and query parameters that usually carry secrets, such as authorization, cookie and token, as [REDACTED]. Do not try to recover them. A replay still sends the original values. Bodies are printed as text: bytes that are not valid UTF-8 are printed as �, and control characters and characters that change the direction of text are printed escaped. A replay still sends the original bytes, so a � doesn't mean that the application sent one.status null, and it stays listed when its client gives up before the application answers.3.293.0 or newer. Check with mirrord --version.mirrord exec) that already received the request. If the list is empty, the request has to be triggered once the usual way."api": false or the environment sets MIRRORD_API=false. Without it, the session keeps no requests.# Requests of the running session
mirrord replay list
# One request: headers, body, and the status of the original response and of its latest replays
mirrord replay show 3
# Send it to the local application again and print the response
mirrord replay send 3
# Change headers first
mirrord replay send 3 --header 'x-tenant: blue' --remove-header authorization
With several local sessions running, add --session-id <ID>, using an id from mirrord session list.
Add --format json to any of them when you parse the output.
List the requests and pick the one to work on, for example the one that failed:
mirrord replay list --format json
Each entry has id, method, path, status (how the application answered the original request, null when it has not answered), and not_replayable, which is null when the request can be replayed and otherwise one of upgraded, body_too_large and body_incomplete.
Read the request, and replay it once to read the failing response body. The original response is kept without its body. If the method is not GET or HEAD, ask the user before this first replay.
mirrord replay show 3 --format json
mirrord replay send 3 --format json
Change the code, and wait for the application to reload if it reloads on change. The session must keep running. If the application has to be restarted with mirrord exec, the session and its requests are gone.
Replay again and compare:
mirrord replay send 3 --format json
The result holds the response of this replay. number counts the replays of the request, starting at 1:
{
"number": 2,
"at_ms": 1795624091971,
"response": {
"status": 200,
"headers": [["content-type", "application/json"]],
"duration_ms": 38
},
"body": { "text": "{\"status\":\"succeeded\"}", "size": 22, "truncated": false }
}
Report the status before and after, and say that the check was a replay of request 3, not a new request through the cluster.
mirrord replay send waits for the response headers as long as the application takes, so it also works while the user holds the request on a breakpoint. It asks the application for an uncompressed response, reads up to 32 KiB of the body for at most 30 seconds, and stops earlier when nothing arrives for 5 seconds, so it only shows the start of a response that streams without end.
| Symptom | Cause and fix |
|---|---|
no local mirrord session is running | Start the application with mirrord exec first. If it is running, its local API is off: remove "api": false from its mirrord config or unset MIRRORD_API=false in its environment, start the session again and trigger the request again. |
several local sessions are running | Pass --session-id with one of the listed ids. |
| The list is empty | The session has not received an HTTP request yet. Trigger one once. Health probes are never listed. |
can't be replayed: its body is larger than the session keeps | The body is over 32 KiB. Trigger the request the usual way. |
can't be replayed: the session doesn't have its whole body | The body is still arriving, the client stopped sending it, or the application answered before all of it arrived. List again in a moment, or trigger the request the usual way. |
the session has no request with id N | The session keeps its latest 100 requests, so older ones are dropped. List again. |
the local application is not listening or a failure to connect | The application is down. A replay waits about three seconds for a restarting application. Replay again once it is up. |
MOmorluto/rea490k8,444 new stars in the last 7 days
MOmorluto/rea490k8,444 new stars in the last 7 days
Diagnose hard bugs and performance regressions by building a feedback loop with tests or scripts.
MAmattpocock/skills340k5,309 new stars in the last 7 days
MAmattpocock/skills340k5,309 new stars in the last 7 days
MAmattpocock/skills340k5,309 new stars in the last 7 days
MAmattpocock/skills340k5,309 new stars in the last 7 days