Repository navigation
Conversation
|
Bumping this in case it was missed. Happy to update it if anything needs changing. |
omegascorp
left a comment
There was a problem hiding this comment.
Thanks for this. The gap is real: these landing handlers and OAuth callbacks catch their own errors and return a 302, so the route handler's captureError never runs for them. Sending them through telemetry makes sense.
One change is needed before we can merge:
These errors must still be printed when telemetry is on. On deployed apps telemetry is enabled, and in that case captureError sends only to APM and prints nothing. Since #343 the Logs page shows only stdout/stderr, so with this PR these auth errors would disappear from the logs and show up in APM alone. Today they are printed. Method and route errors avoid this because something else prints them as well (server.ts, and the route handler's own console.error).
Please make these call sites always print the error and also capture it when telemetry is on. See the inline comment for one way to do it.
Optional nit: the context strings end in a colon ('Error handling magic link landing:'), which reads oddly as an APM error message. Consider dropping the colon.
| } | ||
|
|
||
| getApm().captureError(error); | ||
| if (message) { |
There was a problem hiding this comment.
When telemetry is enabled, nothing reaches the console from here, so the auth errors this PR routes through captureError are no longer printed on deployed apps.
We shouldn't make captureError always print either: methods and routes already print their errors elsewhere, so they would be logged twice. One option is a separate helper for the auth call sites that always prints and also captures when telemetry is on:
export function reportError(error: unknown, message: string) {
console.error(message, error);
if (isTelemetryEnabled()) {
const cause = error instanceof Error ? error : new Error(String(error));
getApm().captureError(cause, { message });
}
}That way the output is the same as today with telemetry off, and the errors reach APM without leaving the logs when it is on. The tests should then check both the console output and the APM call with telemetry enabled.
|
Hi @flcrom, a quick follow-up on the review. #422 has since landed and added |
|
Thanks @flcrom for picking this up and for the clear write-up. Since we didn't hear back, we finished it in #454: each call site now prints with |
Auth failures in the landing handlers, OAuth callbacks and hooks were logged only to the console, so APM missed them. Report them through
captureError, retaining each handler's context in APM and in console output when telemetry is off. User-facing redirects and failures are unchanged.Closes #334
Note
Low Risk
Observability-only: logging path changes with no intended change to auth behavior, redirects, or user-visible errors.
Overview
Auth server-side failures that were only written to
console.errornow go throughcaptureErrorfrom@/telemetry, so they show up in APM when telemetry is enabled. User-facing redirects and error responses are unchanged.captureErrornow accepts an optional contextmessage(andunknownerrors). With telemetry off, the console fallback logsmessageplus the error; with telemetry on, the message is passed to APM as custom context.Call sites include magic-link landing and hook failures, token-restore errors, password-reset landing, email verification, GitHub/Google OAuth callbacks, OAuth error redirect /
errorComponentfailures, and OAuth hook execution. Tests mock@/telemetryand assertcaptureErroris invoked with the same context strings that used to appear in console logs.Reviewed by Cursor Bugbot for commit 130a284. Bugbot is set up for automated code reviews on this repo. Configure here.