Summary
Each time the OAuth access token is refreshed, the plugin calls upsertPluginConfig() which rewrites ~/.openclaw/openclaw.json with the new accessToken and refreshToken. OpenClaw detects this config file change and triggers a full gateway restart (by design — the config watcher restarts on sensitive field changes).
This causes the gateway to restart multiple times per hour, which:
- Interrupts running cron jobs (they land in a "missed jobs after restart" queue and execute late)
- Creates a noisy restart loop visible in logs all day
- Breaks timed automation workflows that depend on stable scheduling
Observed behavior
Logs show a clear pattern repeating ~every 15–60 min:
config change detected; evaluating reload (plugins.entries.openclaw-membase.config.accessToken, plugins.entries.openclaw-membase.config.refreshToken)
config change requires gateway restart (plugins.entries.openclaw-membase.config.accessToken, plugins.entries.openclaw-membase.config.refreshToken)
membase: stopped
membase: connected (recall: true, capture: true)
Root cause
upsertPluginConfig() in src/commands/cli.ts writes the refreshed tokens directly into openclaw.json. Since accessToken and refreshToken are listed as sensitive fields that require gateway restart when changed, every token rotation restarts the entire gateway.
Proposed fix
Store the OAuth tokens in a separate file (e.g., ~/.openclaw/extensions/openclaw-membase/tokens.json) and only keep stable config values (apiUrl, clientId, tokenFile) in openclaw.json.
Changes needed:
src/config.ts: Add readTokenFile() and writeTokenFile() helpers; load tokens from the file at plugin load instead of from pluginConfig
src/index.ts: Call writeTokenFile() in the onTokenRefresh callback instead of upsertPluginConfig(); auto-migrate existing tokens on first boot
src/commands/cli.ts: Update login and logout to write/clear the token file; only persist apiUrl, clientId, and tokenFile path to openclaw.json
openclaw.plugin.json: Add tokenFile to the config schema
src/types.ts: Add tokenFile: string to MembasePluginConfig
This way, token refreshes only touch the private token file — which OpenClaw does not watch for config-triggered restarts — leaving the gateway stable.
Workaround applied locally
We implemented the patch described above locally on @membase/openclaw-membase@0.3.1. The gateway has been stable since applying it. Happy to share the diff if useful.
Environment
- openclaw-membase version: 0.3.1
- OpenClaw version: 2026.3.12
- OS: Ubuntu 24.04 LTS
Summary
Each time the OAuth access token is refreshed, the plugin calls
upsertPluginConfig()which rewrites~/.openclaw/openclaw.jsonwith the newaccessTokenandrefreshToken. OpenClaw detects this config file change and triggers a full gateway restart (by design — the config watcher restarts on sensitive field changes).This causes the gateway to restart multiple times per hour, which:
Observed behavior
Logs show a clear pattern repeating ~every 15–60 min:
Root cause
upsertPluginConfig()insrc/commands/cli.tswrites the refreshed tokens directly intoopenclaw.json. SinceaccessTokenandrefreshTokenare listed as sensitive fields that require gateway restart when changed, every token rotation restarts the entire gateway.Proposed fix
Store the OAuth tokens in a separate file (e.g.,
~/.openclaw/extensions/openclaw-membase/tokens.json) and only keep stable config values (apiUrl,clientId,tokenFile) inopenclaw.json.Changes needed:
src/config.ts: AddreadTokenFile()andwriteTokenFile()helpers; load tokens from the file at plugin load instead of frompluginConfigsrc/index.ts: CallwriteTokenFile()in theonTokenRefreshcallback instead ofupsertPluginConfig(); auto-migrate existing tokens on first bootsrc/commands/cli.ts: Updateloginandlogoutto write/clear the token file; only persistapiUrl,clientId, andtokenFilepath toopenclaw.jsonopenclaw.plugin.json: AddtokenFileto the config schemasrc/types.ts: AddtokenFile: stringtoMembasePluginConfigThis way, token refreshes only touch the private token file — which OpenClaw does not watch for config-triggered restarts — leaving the gateway stable.
Workaround applied locally
We implemented the patch described above locally on
@membase/openclaw-membase@0.3.1. The gateway has been stable since applying it. Happy to share the diff if useful.Environment