{"record":{"id":"d2c3c77e508397f0","repo":"nextcloud/all-in-one","slug":"error-while-fetching-log-data","errorCode":null,"errorMessage":"Error while fetching log data!","messagePattern":"Error while fetching log data!","errorType":"console","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"php/public/log-load.js","lineNumber":74,"sourceCode":"    debug(...args) {\n        if (this.debugLog) {\n            console.debug('LogViewer:', ...args);\n        }\n    }\n\n    // Load log data and append it to the DOM.\n    loadAndAppendLogData() {\n        if (this.dataLoadingLock) {\n            this.debug(\"Another log data loading request is still running, cancelling this request\");\n            return;\n        }\n        this.debug(\"Loading new log data\");\n        this.dataLoadingLock = true;\n        this.loaderElem.classList.remove('hidden');\n        fetch(this.getUrl())\n            .then((response) => {\n                if (!response.ok) {\n                    throw new Error(\"Error while fetching log data!\");\n                }\n                return response;\n            })\n            .then((response) => response.text())\n            .then((text) => {\n                text = text.trim();\n                if (text.length === 0) {\n                    this.debug(\"Received no new log data from server\");\n                    return;\n                }\n                this.debug(\"Received\", Math.round(text.length / 1024), \"KB of new log data from server\");\n                this.logElem.append(text + \"\\n\");\n                this.scrollToBottom();\n                this.lastLogTimestamp = text.split(\"\\n\").at(-1)?.split(' ')[0] ?? '';\n            })\n            .finally(() => {\n                this.dataLoadingLock = false;\n                this.loaderElem.classList.add('hidden');","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/nextcloud/all-in-one/blob/6b788eec5e61733cf03ed380a3572e43ae3f11ce/php/public/log-load.js#L56-L92","documentation":"Thrown by the LogViewer class of the Nextcloud AIO web interface when the browser fetch() to 'api/docker/logs?id=<containerId>&since=<ts>' returns a non-2xx HTTP status (response.ok === false). That endpoint is served by the AIO mastercontainer's PHP backend (DockerController::GetLogs), which answers 200 even for unknown container ids, so a non-2xx status means the request never reached the log handler successfully: the mastercontainer or its Apache container is down/restarting, authentication middleware rejected the session, or a reverse proxy in front returned 502/503. The promise chain catches the error and logs it to the browser console; the 5-second autoload interval keeps retrying, so single occurrences are usually transient.","triggerScenarios":"Opening the container-logs page while the nextcloud-aio-mastercontainer or its Apache container is restarting; the PHP backend dying mid-poll so the next fetch gets 5xx; an expired/invalid session cookie so auth middleware answers 401; a reverse proxy or CDN in front of the AIO interface briefly returning 502/503; transient network loss between browser and server.","commonSituations":"Watching logs during a container update or restart; browser tab left open overnight while the server reboots; AIO interface behind a reverse proxy whose upstream is briefly down; laptop resuming from sleep with stale connections.","solutions":["Wait for the next 5-second poll — the viewer retries automatically and usually self-heals; check whether the console error repeats","Verify the containers are up: 'sudo docker ps' and 'sudo docker logs -f nextcloud-aio-mastercontainer' (the mastercontainer and its Apache container must be running)","Reload the log page (and re-login if the session expired) so a fresh authenticated fetch is made","If the interface sits behind a reverse proxy, inspect its logs for 502/503 and fix the upstream to the mastercontainer"],"exampleFix":"// before\nif (!response.ok) {\n    throw new Error(\"Error while fetching log data!\");\n}\n// after\nif (!response.ok) {\n    throw new Error(`Error while fetching log data! (HTTP ${response.status} ${response.statusText})`);\n}","handlingStrategy":"retry","validationCode":"// Cheap pre-check inside loadAndAppendLogData() before fetch():\nif (!navigator.onLine) {\n    this.debug('Browser offline, skipping log fetch');\n    return;\n}","typeGuard":"/**\n * @param {unknown} err\n * @returns {boolean} true when the failure was the HTTP-status check (not a network error)\n */\nfunction isHttpError(err) {\n    return err instanceof Error && err.message === 'Error while fetching log data!';\n}","tryCatchPattern":".catch((err) => {\n    console.error(err);\n    // The finally-block already released dataLoadingLock and hid the loader,\n    // so no state is stuck; the 5 s autoload interval retries automatically.\n    // Optionally count consecutive failures and stop autoloading after N.\n})","preventionTips":["Include response.status in the thrown message so failures are diagnosable from the console alone","Keep the loader/lock release in .finally() so failed polls never wedge the viewer","Keep the AIO mastercontainer and its Apache container running while log pages are open","Monitor any reverse proxy in front of the interface for 502/503 responses"],"tags":["javascript","fetch","http-status","nextcloud-aio","log-viewer","browser"],"backgroundTag":"http-response-not-ok","analyzedSha":"6b788eec5e61733cf03ed380a3572e43ae3f11ce","analyzedAt":"2026-08-21T05:47:24.382Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}