Deploy, Monitor and Fix
Read the Logs, Then Hand AI the Evidence
What the Error Codes Mean
| Visitor sees | What happened |
|---|---|
| 1101 | Your code threw an error |
| 1102 | Too much CPU time or memory |
| 1027 | Free plan ran out of requests for the day |
| 1103 | Blocked. Check if you hit your own spending limit |
npx wrangler tail --status error shows errors live. Observability in the dashboard keeps the last 7 days on paid.
Logs Are Something You Ask For
console.error("job failed", { id: msg.body.id, error: String(err) });
What failed, which one, why. Put it in the spec: every catch logs what it was doing and an ID. The worst code AI writes is catch {} with nothing in it. It didn't handle the error. It hid it.
Never log passwords, tokens or whole request bodies. An ID is enough to go find the rest.
Don't Say "It's Broken, Fix It"
Do that and AI will change something. Maybe the right thing. Give it evidence and make it prove the cause:
Here is the log line, the stack trace, the route, and the time it started.
Here is the last deploy before it started.
1. Give me the three most likely causes, and the evidence for each.
2. Tell me the one command or query that would rule each one out.
3. Reproduce the failure locally with a failing test. Do not fix it yet.
Do not change code until we have seen it fail.
That last line is the whole trick. If it never saw the failure, it can't know it fixed it. After the fix, the same test has to pass, and then you go look at the live page.
And ask: "Where else do we do this same thing?" A bug in one place is usually a habit in five.
Two failed fixes in a row means the theory is wrong. Stop. Start a fresh session, give it the raw evidence without the old theory, and let it look again.
What should AI do before changing code to fix a live error?