Sync init self-terminates the whole MCP server
Back to board**Environment**
| | |
|---|---|
| Plugin version | 2.11.3 (current `@latest`) |
| MCP server version | 2.11.3, launched as `npx -y @weppy/roblox-mcp@latest` (stdio) |
| AI client | Claude Code |
| OS | Windows 11 Pro (build 26200) |
| Node.js | v24.16.0 |
| Roblox Studio | 0.732.0.7321040 |
| Tier | PRO |
| Place | ~4,500 instances, ~150 scripts, ~2.8 MB script source |
**Steps**
1. Use a sync-enabled place on Windows.
2. Start a full sync from the plugin — manually, via auto-start on connect, or via the automatic
sync restart after a playtest. All three triggers produced the failure here.
3. During sync init the server writes the observability changelog session file
(`<syncRoot>\observability\changelog\sessions\sync-only_<placeId>_<minute>.jsonl`) via
tmp-file + rename. When that rename fails with `EPERM`, the resulting unhandledRejection
**shuts down the entire MCP server**
4. Frequency here: intermittent chunk-timeout failures on 2026-07-29/30 (second attempt passed),
then escalation — six incidents total through 2026-08-02, including **every** sync start on
2026-08-01, on cold and warm servers, and after a full PC reboot (one clean sync right after
the reboot, crashes resumed the next day). Working with sync disabled is completely stable on
the same setup.
### Expected behavior
- A failed write/rename of an observability/changelog file (`EPERM` is a normal, transient
Windows condition — AV scans, concurrent handles) should be retried or skipped; it must never
raise an unhandledRejection that shuts down the whole MCP server.
- A chunk-upload timeout during `/sync/init` should be retried or fail the sync gracefully; it
should never take the server process down.
- The failure should be written to the observability file logs (it currently is not
### Actual behavior
**Root cause captured (2026-08-02, server console output).** The process does not crash — it
**shuts itself down on an unhandledRejection** raised by an **EPERM rename of the observability
changelog session file** ~2.5 s into sync init:
```
[00:05:11] [INFO] Full sync started { totalServices: 11, totalInstances: 4412, ... }
[00:05:13] [ERROR] Shutdown requested by unhandledRejection
Error: EPERM: operation not permitted, rename
'<syncRoot>\observability\changelog\sessions\sync-only_<placeId>_2026-08-02T00_05_00.000Z.jsonl.tmp-16388-<uuid>'
-> '<syncRoot>\observability\changelog\sessions\sync-only_<placeId>_2026-08-02T00_05_00.000Z.jsonl'
at async Object.rename (node:internal/fs/promises:785:10)
at async zfe (dist/index.js:68:595)
at async fn (dist/index.js:68:843)
at async (dist/index.js:82:286)
at async G8 (dist/index.js:82:318)
at async Wl (dist/index.js:93:1476)
at async J9 (dist/index.js:533:4588)
[00:05:13] [INFO] Stopping MCP Server
[00:05:18] [ERROR] Shutdown timed out, forcing process exit
```
This is consistent with every symptom of the other incidents: the plugin-side
`Failed to send chunk N/M … Request timeout: /sync/init` (the server is shutting down mid-init),
the silent death, and why only sync start triggers it (that is when the session file is written).
The console was only visible for THIS incident; the earlier ones match the same external
fingerprint but their console output was not captured.
**All dated occurrences**
| Date (UTC) | Plugin UI message / source | Outcome |
|---|---|---|
| 2026-07-29 | `Failed to send chunk 17/35 for ServerStorage: Request timeout: /sync/init` | immediate second attempt completed |
| 2026-07-30 (session start) | `Failed to send chunk 20/35 for ServerStorage: Request timeout: /sync/init` | immediate second attempt completed |
| **2026-07-31 ~18:50** | `Failed to send chunk 5/8 for Workspace: Request timeout: /sync/init` (manual sync start) | **MCP server process died**; `http://127.0.0.1:3002/status` refuses; `/mcp` restart recovers |
| **2026-08-01 10:37–11:30** | (no UI message captured; log ends silently after `Auto-starting sync...`) | **three sync starts, zero completed; at least two server deaths** |
| **2026-08-01 23:54** | Studio buffer: `Failed to send chunk 1/36 for ServerStorage` (sync auto-restart after a playtest) | **server process died** |
| **2026-08-02 00:05** | server console captured — excerpt above | **EPERM → unhandledRejection → self-shutdown** |
**File-level forensics, verified minutes after the 2026-08-02 death (facts)**
- The rename TARGET file exists with **14 entries**, all timestamped `00:05:11.555–.590` (during
the full sync), and its mtime is `00:05:13` — the death second. So at least one earlier flush
cycle onto the same target had succeeded before a later rename got EPERM.
- No `.tmp-…` leftover remained in `changelog\sessions`, and the target file was **no longer
locked** when tested afterwards. The lock holder at the moment of the EPERM is therefore
**not identifiable after the fact** — the entries carry no instance/pid markers.
- No weppy node process was left running after the forced exit.
**Already ruled out**
- [x] Native crash — no Windows Error Reporting event and no crash dump for node.exe across all
incidents (36 h window checked, `%LOCALAPPDATA%\CrashDumps` empty); the shutdown is deliberate.
- [x] Corrupt sync index (the fixed 2.11.1 issue) — `.sync-index.json` was intact (4.16 MB) during
the incidents.
- [x] Place size / payload — the same place completed full syncs fine before 2026-07-29 and once
after a reboot (4,372 instances / 157 scripts).
- [x] Stale process/system state — reproduced within a day after a full PC reboot.
- [x] Cold-start-only — incident #3 on 2026-08-01 hit a warm, freshly reconnected server.
**Unverified candidates for the EPERM itself (hypotheses, not needed for the fix):**
(a) a second MCP instance — one registered in client mode 3 s before the 2026-08-02 death, both
instances share the data dir, and the session filename is minute-bucketed, so concurrent writers
are possible; (b) an AV/indexer briefly locking the just-replaced `.jsonl`/`.tmp`. We could not
distinguish these afterwards. What IS actionable regardless of the lock holder: a telemetry write
failure must not take the server down.
**The failure never reaches the FILE logs.** Both `observability/logs/current.log` and the
daily plugin log simply **end at the last successful entry** before each death:
```
[2026-07-31 18:47:57] [INFO] Executed: manage_camera_screenshot (803ms)
[2026-07-31 18:48:13] [INFO] Executed: execute_luau (1ms)
<end of file — sync started from plugin around 18:50, chunk 5/8 timeout shown in UI,
server process dead, nothing further logged>
```
```
[2026-08-01 11:26:29] [INFO] Session ID: <…>
[2026-08-01 11:26:29] [INFO] MCP Version: 2.11.3
[2026-08-01 11:26:29] [INFO] Auto-starting sync...
<end of file — server process dead shortly after (port 3002 refuses connections)>
```
**But the in-Studio log buffer (plugin-side, `manage_logs`) survives server deaths** and holds
the full pre-death sequence — pull it after a `/mcp` restart when reproducing. Example, the
2026-08-01 23:54 incident (sync auto-restart after a playtest):
```
[SyncManager] stopSync begin: state=idle ... (23:54:14, post-playtest)
[SyncManager] Error: Failed to send chunk 1/36 for ServerStorage: Request timeout: init (23:54:45)
[SyncManager] init session cleanup failed: Request timeout: stop
[SyncWatcher] Stopped
<server still answered pings for ~3 more minutes, then process gone — port 3002 refuses>
```
One earlier sequence (~23:26 UTC 2026-08-01, silent background reconnect + sync auto-start) also
contained a plugin-side error — offered as data, it appeared only this once and may be a symptom
of an already-unresponsive server rather than a cause:
```
[WeppyRobloxMCP] Command channel connection attempt started...
ERROR: cannot spawn non-suspended coroutine with arguments
Stack: Script 'user_WeppyRobloxMCP.rbxm.WeppyRobloxMCP.CommandChannel.WsTransport', Line 12
[SyncManager] Error: Failed to send chunk 18/35 for ServerStorage: Request timeout: init
```
Possibly related context (cause unproven, offered as data): silent WebSocket reconnects became
much more frequent on this setup in the same period — `current.log` shows `Reconnecting...` with
no preceding error (15.06–23.07: 0–3/day at higher activity; 30.07: five; 31.07: five). Each
reconnect returns ~1 s later with a new session ID.