diff --git a/client/backoff.ts b/client/backoff.ts index 7d0ae55..ff62c40 100644 --- a/client/backoff.ts +++ b/client/backoff.ts @@ -65,7 +65,7 @@ export const retryWithBackoff = async ( return; } const timeout = backoff.next(); - logger.info( + logger.debug( { nextTimeout: timeout, count, error: e }, "Retrying with backoff timeout" ); diff --git a/server/auth.ts b/server/auth.ts index cef3888..f37b78e 100644 --- a/server/auth.ts +++ b/server/auth.ts @@ -20,6 +20,7 @@ export class AuthorizationError extends Error { } } +// Errors would be logged on every attempt from the braekhus proxy to connect, only log with debug level export const validateAuth = async ( authorization: string | undefined, publicKeyGetter: PublicKeyGetter @@ -27,26 +28,26 @@ export const validateAuth = async ( if (!authorization) throw new AuthorizationError(); const match = authorization.match(AUTH_PATTERN); if (!match || !match[1]) { - logger.error("Bearer token not found"); + logger.debug("Bearer token not found"); throw new AuthorizationError(); } const jwt = match[1]; const clientId = jose.decodeJwt(jwt).sub; logger.debug({ clientId }, "Validating client ID"); if (!clientId) { - logger.error({ clientId }, "Client ID not found"); + logger.debug({ clientId }, "Client ID not found"); throw new AuthorizationError(); } const key = await publicKeyGetter(clientId); if (!key) { - logger.error({ clientId }, "Public key not found"); + logger.debug({ clientId }, "Public key not found"); throw new AuthorizationError(); } const jwk = await jose.importJWK(key as any, ALG); try { await jose.jwtVerify(jwt, jwk, { subject: clientId, audience: "p0.dev" }); } catch (error: any) { - logger.error({ clientId, error }, "Error during verification"); + logger.debug({ clientId, error }, "Error during verification"); throw new AuthorizationError(); } }; diff --git a/server/index.ts b/server/index.ts index 46dea54..f412389 100644 --- a/server/index.ts +++ b/server/index.ts @@ -263,7 +263,7 @@ export class RemoteClientRpcServer extends JsonRpcServer { onChannelConnection(channelId: ChannelId, channel: JSONRPCServerAndClient) { channel.addMethod("setClientId", ({ clientId }) => { - this.#logger.info({ channelId, clientId }, "Setting client ID"); + this.#logger.debug({ channelId, clientId }, "Setting client ID"); this.addChannel(channelId, clientId); return { ok: true }; }); @@ -325,7 +325,8 @@ export class JsonRpcApp { await validateAuth(request.headers.authorization, publicKeyGetter); this.#rpcServer.handleUpgrade(request, socket, head); })().catch((error: any) => { - this.#logger.error({ error }, "Error upgrading connection"); + // Logged on every attempt from the braekhus proxy to connect, only log with debug level + this.#logger.debug({ error }, "Error upgrading connection"); const body = JSON.stringify({ error }, undefined, 2); const code = error.code ?? 500; const reason = error.reason ?? "Internal Server Error";