-
Notifications
You must be signed in to change notification settings - Fork 351
Description
I maintain a worker that runs some code to authenticate requests made to it, like:
[...]
use worker::{event, Context, Env, Method, Request, Response, console_log};
[...]
#[event(fetch)]
async fn main(mut req: Request, env: Env, _ctx: Context) -> WorkerResult<Response> {
[...]
match check_auth(&req, &env).await {
Ok(true) => {}
Ok(false) => return Response::error("Unauthorized", 401),
Err(e) => {
return Response::error(
format!("Error attempting to authenticate request: {e}"),
401,
)
}
};
[...]
For several hours I was hitting the Ok(false) => return Response::error("Unauthorized", 401),
condition in one environment that uses this worker. But my Workers & Pages
dashboard for this worker shows 0 errors, 0 errors by version, and 0 errors by invocation status, for the entire duration of this misconfiguration in that environment. I would have expected to have seen errors on the dashboard, but instead I had to run over to the logs. And because the logs are grouped with their invocation logs, it wasn't obvious which requests were failing until I clicked on each invocation log and viewed its sub-logs and saw auth error logs in the affected invocations.
I'm assuming there's a way to bubble these errors up to the dashboard's error counters. But honestly not sure how, if that's not the job of Response::error