From 0afb9469582f0517eeb3eeb2f92b8f8770a7c4f7 Mon Sep 17 00:00:00 2001 From: samson910022 Date: Mon, 28 Sep 2026 18:17:12 +0800 Subject: [PATCH] fix(docker): pin backend project config read-only to stop abort storm opencode serve rewrites /config.json on every API call (ConfigHttpApi.update) and its file watcher treats that as a config change, disposing/recreating the project instance and aborting in-flight session work (MessageAbortedError -> response.failed 'Aborted' -> client retry loop). Lock a skeleton config.json root-owned 644 at container boot so the write fails without mtime change and the watcher stays quiet. --- entrypoint.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 7d1fe42..ba57ead 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -68,7 +68,23 @@ fi if [[ "$1" == "opencode" && "$2" == "serve" ]]; then echo "Initializing OpenCode-to-OpenAI (Server + Proxy)" - + + # opencode serve rewrites /config.json on (nearly) every API call + # (ConfigHttpApi.update) and its own file watcher treats that as a config + # change: it disposes/recreates the project instance, aborting in-flight + # session work. Under concurrent/rapid proxy traffic this becomes a + # self-sustaining abort storm (backend MessageAbortedError -> proxy + # response.failed "Aborted" -> client retries -> more reloads). + # Pin a skeleton config.json root-owned/read-only for the node user so the + # write fails (EACCES, logged by the backend, otherwise harmless) without + # changing mtime, which keeps the watcher quiet. No real settings live in + # this file (backend state stays under /home/node/.local/share/opencode). + if [ ! -f /home/node/project/config.json ]; then + printf '{\n "$schema": "https://opencode.ai/config.json"\n}\n' > /home/node/project/config.json + fi + chown root:root /home/node/project/config.json + chmod 644 /home/node/project/config.json + echo "Starting OpenCode Server on internal port ${SERVER_PORT}..." gosu node opencode serve --hostname 0.0.0.0 --port ${SERVER_PORT} & SERVER_PID=$!