Skip to content

[Bug]: dsh-memory-plugin stops reconnecting before the server finishes starting #7738

Open

Description

@lztxwd6666

Issue Origin

Observed or reproduced in a real environment

Bug Description

The plugin never passes a reconnect policy to the dsh-mcp-client instance it mounts, so the bridge falls back to the defaults shipped with DSH:

RECONNECT_DEFAULTS = { enabled: true, initialDelayMs: 500, maxDelayMs: 30000, maxAttempts: 10 }

Those ten attempts add up to about 150 seconds of backoff. And when they run out, the bridge doesn't slow down — it stops. It unregisters every tool and schedules nothing further:

if (failedAttempts > policy.maxAttempts) {
  syncChain = syncChain.then(clearTools);        // every openviking tool unregistered
  status.update({ state: "failed", reason: "gave-up" });
  ctx.logger.error(`${label}: giving up after ${policy.maxAttempts} consecutive failed reconnect attempts — tools unregistered; reload the plugin or restart the Host to reconnect`);
  return;                                        // no timer, no retry, nothing
}

The trouble is that 150 seconds is shorter than the server's own startup. On this machine OpenViking takes around 70 seconds just to bind its port — the models warm up first, and the listener comes after. A restart with any real work in it takes longer than that. The proxy, meanwhile, starts instantly and fails immediately while the endpoint is down, so the bridge spends its entire budget in the first two and a half minutes, before the server is even listening.

One server restart is therefore enough to kill memory for the rest of the session. /health answers {"status":"ok"}, ov health is green, the plugin row still says fiberPhase: active, and every tool call returns:

mcp-client(openviking): server is disconnected

It stays like that until the plugin is reloaded or the host is restarted. The only clue is a single line buried in the host log.

Worth saying plainly: this is not a dsh-mcp-client bug. DSH exposes reconnect on the config exactly so an integration can size the budget to its own server's startup. A long-running background daemon, of all things, is the one that needs the wider window.

Steps to Reproduce

  1. Install @openviking/dsh-memory-plugin@0.5.36 in a DSH profile pointed at a local OpenViking server.
  2. Check the bridge is up: mcp__openviking__health returns healthy.
  3. Stop the server and leave it down for more than ~150 seconds.
    Stop-Process -Name openviking-server -Force
    Get-NetTCPConnection -LocalPort 1933 -State Listen   # empty
  4. Start it again and wait for the listener — around 70 seconds here.
    Start-Process <openviking-install>\openviking-server.exe -WindowStyle Hidden
    do { Start-Sleep 5 } until (Get-NetTCPConnection -LocalPort 1933 -State Listen -ErrorAction SilentlyContinue)
    Invoke-WebRequest http://127.0.0.1:1933/health -UseBasicParsing   # 200
  5. Call any bridged tool.

Expected Behavior

The bridge should notice the server is back and reconnect on its own, the way it does for any other MCP server. Restarting a local daemon is routine, and this one takes a minute and change to come up, so the recovery window ought to cover that.

The fix is small — give the mount an explicit policy:

return {
  transport: "stdio",
  serverName: MCP_SERVER_NAME,
  command: process.execPath,
  args: [PROXY_PATH],
  env,
  toolCallTimeoutMs: config.mcpToolCallTimeoutMs,
  reconnect: {
    enabled: true,
    initialDelayMs: 1000,
    maxDelayMs: 30000,
    maxAttempts: 60,
  },
};

That buys roughly twenty minutes while keeping the backoff ceiling and leaving the first attempt immediate. It validates cleanly against the bridge's own schema:

{"enabled":true,"initialDelayMs":1000,"maxDelayMs":30000,"maxAttempts":60}

There's a PR attached with this change plus a regression test.

Actual Behavior

After step 4 the server is confirmed healthy, yet every tool keeps returning:

mcp-client(openviking): server is disconnected
list_mcp_resources -> mcp-client(openviking): server is disconnected

plugin_manager list_plugins still shows include:openviking-memory-runtime as enabled: true / fiberPhase: active, which makes it look like a plugin problem. It isn't — the plugin is fine, the MCP generation is simply gone.

Minimal Reproducible Example

The difference is easy to see against the bridge's own config schema:

const m = await import("@deepseek-ai/dsh-mcp-client");
const base = { transport: "stdio", serverName: "openviking", command: "x", args: [] };

m.Config(base).reconnect;
// { enabled: true, initialDelayMs: 500, maxDelayMs: 30000, maxAttempts: 10 }
// -> 500 + 1000 + 2000 + 4000 + 8000 + 16000 + 30000*4 = 151500 ms

m.Config({ ...base, reconnect: { enabled: true, initialDelayMs: 1000, maxDelayMs: 30000, maxAttempts: 60 } }).reconnect;
// { enabled: true, initialDelayMs: 1000, maxDelayMs: 30000, maxAttempts: 60 }
// -> about 20 minutes

Against the measured 70-second cold start, the default budget is roughly half of what one restart needs.

Error Logs

mcp-client(openviking): connection failed; retrying in 500ms (attempt 1/10)
...
mcp-client(openviking): giving up after 10 consecutive failed reconnect attempts
  — tools unregistered; reload the plugin or restart the Host to reconnect

Server side, healthy throughout the retry window:

OpenViking HTTP Server is running on 0.0.0.0:1933
$ curl -s http://127.0.0.1:1933/health
{"status":"ok","healthy":true,"version":"0.5.5","auth_mode":"api_key"}

OpenViking Version

0.5.5, with @openviking/dsh-memory-plugin@0.5.36

Python Version

3.11

Operating System

Windows

Model Backend

Other

Additional Context

The failure hits local servers harder than remote ones. A remote endpoint that blips for two minutes recovers fine; a local daemon that the user restarts by hand almost never does, because its own boot time is longer than the budget.

Related reading, though a different problem: #6957 (startup latency from serial agent/created calls) and #6742 (eager session creation). Those are about cost; this one is about recovery.

Until it's fixed, the workaround is to force a reload after the server is back — touching the profile's cordis.patch.yml, or restarting the host. There's no way to revive a given-up bridge from the UI.

One more thing worth flagging for anyone running this on Windows, purely as an aside: launching the server from a DSH tool call puts it inside the host's KILL_ON_JOB_CLOSE job object, so closing the desktop app takes the server down with it. Running it as a Windows service (nssm, auto-restart, session 0) avoids both that and the popups you get from a polling scheduled task. It has nothing to do with the reconnect gap above, but it's the other half of the same bad afternoon.

Activity

  1. moved this from Backlog to In progress in OpenViking projecton Nov 16, 2026
  2. lztxwd6666 commented on Nov 16, 2026

    @lztxwd6666
    Author

    Correction to the recovery note below, after r266-tech pointed out that my measurement was testing the wrong path.

    A later HTTP blip does not tear the stdio proxy down: it exits only on stdin close or a signal, and its own sendWithRetry reinitializes the HTTP session on 400/404. So stopping the server and waiting proves nothing about the reconnect budget — the supervisor never enters its reconnect branch, and what I watched recover was the proxy's session handling.

    The case that actually exhausts the budget is an initialization that fails — which is exactly what the original incident was: the server died while the host was restarting, so the first attempt had nothing to reach.

    Re-ran it that way. Server down, plugin remounted so the first connect fails:

    • 214 s later: tools still registered and still reaching the transport, past the 151,500 ms main spends before it unregisters everything.
    • Server restored after 233 s, listener up 35 s later. Bridge reconnected on its own, list and find fine, no host restart, no reload.

    So the fix holds, but the earlier evidence did not demonstrate it. The rest of that comment — the separate 10 s timeoutMs and the job-object launch issue — stands as written.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions