From fa2d6d9a2d176be053eaa8b0f0954605fa0e193e Mon Sep 17 00:00:00 2001 From: "dkoosis@gmail.com" Date: Fri, 26 Dec 2025 17:42:30 -0500 Subject: [PATCH] Fix HTTP 500 errors locking client outside offline mode When the server returns HTTP 500 or other 5xx errors, the client was caching the error HTML page (e.g., Nginx error pages) and attempting to parse it as JSON on boot, causing a lockout with the message 'Could not process config and no cached copy'. This fix adds all standard 5xx server error codes to the offlineStatusCodes list, ensuring the client enters offline mode and uses cached data instead of caching error responses. Before: Only 502, 503, 504, 530 triggered offline mode After: All 5xx errors (500-511, 530) trigger offline mode Fixes #1724 --- plug-api/constants.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plug-api/constants.ts b/plug-api/constants.ts index 08cc940e..924ab969 100644 --- a/plug-api/constants.ts +++ b/plug-api/constants.ts @@ -20,11 +20,23 @@ export const pingInterval: number = 5000; * * This enables SilverBullet to work in a true "offline-first" manner, falling back to cached * content when the backend is unavailable through no fault of the user's network connection. + * + * All 5xx server errors are included to prevent the client from caching error HTML pages + * (e.g., Nginx 500 error pages) which would prevent the client from booting in offline mode. */ export const offlineStatusCodes = { + 500: "Internal Server Error", // Server encountered an unexpected condition + 501: "Not Implemented", // Server does not support the functionality required 502: "Bad Gateway", // Proxy server received invalid response from upstream server 503: "Service Unavailable", // Server is temporarily unable to handle the request 504: "Gateway Timeout", // Proxy server did not receive a timely response from upstream server + 505: "HTTP Version Not Supported", // Server does not support the HTTP version + 506: "Variant Also Negotiates", // Server has an internal configuration error + 507: "Insufficient Storage", // Server is unable to store the representation + 508: "Loop Detected", // Server detected an infinite loop while processing + 509: "Bandwidth Limit Exceeded", // Server bandwidth limit has been exceeded + 510: "Not Extended", // Further extensions to the request are required + 511: "Network Authentication Required", // Client needs to authenticate to gain network access 530: "Unable to resolve origin hostname", // Served when cloudflared is down on the host } as const;