From 04af6e9f4dbf9ee28c46e5d0eedc893a16245a35 Mon Sep 17 00:00:00 2001 From: "prompt.ac/@jeffrey" Date: Sat, 8 Aug 2026 01:31:54 -0700 Subject: [PATCH] Treat a missing handle as normal, not a fetch failure A user who has not claimed a handle gets a 404 from the handle API whose body is an HTML error page. The response was parsed as JSON regardless, so the parse threw and every handle-less login logged as 'Failed to fetch handle: Unexpected token <'. Read the body only when the response is ok and actually JSON; anything else now logs calmly as no-handle. --- session-server/session.mjs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/session-server/session.mjs b/session-server/session.mjs index ac5b99cf51..35ee2ba8e1 100644 --- a/session-server/session.mjs +++ b/session-server/session.mjs @@ -2561,9 +2561,19 @@ wss.on("connection", async (ws, req) => { fetch(`https://aesthetic.computer/handle/${encodeURIComponent(userSub)}`) .then(response => { log("📡 Handle API response status:", response.status, "for", userSub.substring(0, 20) + "..."); + // A user who hasn't claimed a handle gets a 404 whose body is an + // HTML error page. Parsing that as JSON throws, which made the + // ordinary no-handle case log as a failure. Only read the body + // when it is actually JSON; anything else means "no handle". + const type = response.headers.get("content-type") || ""; + if (!response.ok || !type.includes("application/json")) return null; return response.json(); }) .then(data => { + if (!data) { + log("⚠️ User logged in (no handle):", userSub.substring(0, 12) + "...", "connection:", id); + return; + } log("📦 Handle API data:", JSON.stringify(data), "for connection:", id); if (data.handle) { clients[id].handle = data.handle; -- 2.51.2