Skip to content

[Bug]: New conversations fail with "Global daemon is already initialized with different options" when another plugin sets a process.env variable #101

In review

Description

@chenzhoucn

Qoderian version

Qoderian 1.0.19 (latest release)

qodercli version

  • qodercli 1.1.97

Obsidian and operating system

  • Obsidian desktop, Windows 11 - Another installed plugin: Copilot 4.0.20 (bundles Claude Agent SDK 0.3.306), loaded a few seconds after Qoderian by lazy-plugins

Reproduction steps

2.3 Steps to reproduce

  1. Install Qoderian and Copilot in the same vault, with Copilot loading after Qoderian.
  2. Start Obsidian and wait until Qoderian has initialized its daemon.
  3. Trigger a Claude agent query in Copilot (it runs process.env.CLAUDE_AGENT_SDK_VERSION = "0.3.306").
  4. Open a new Qoderian tab.

2.4 Actual behavior

The new tab shows the error above. ~/.qoder/logs/sdk-daemon-*.log records:

[GlobalDaemon] init rejected: configuration conflict with the ready daemon

2.5 Expected behavior

A variable written to process.env by an unrelated plugin should not prevent Qoderian from reusing its daemon.

2.6 Diagnosis

  • buildDaemonLaunchOptions() spreads the whole process.env into env.
  • The SDK's global daemon compares the stored options with the incoming ones. env is compared over the union of keys, so a key that appears later counts as a conflict.
  • I instrumented the comparison and logged the diff on every conflict (7 conflicts, all identical). Every other field matched (auth, launchMode, pathToQoderCLIExecutable, executable, executableArgs, proxy, noProxy, vpcEndpoint). env differed in exactly one key:
{"key":"CLAUDE_AGENT_SDK_VERSION","stored":null,"incoming":"0.3.306"}
  • The value 0.3.306 only exists in Copilot's main.js, inside its bundled Claude Agent SDK query() function.
  • Timeline from the logs:
19:58:53  [DaemonLaunch] command=...\qodercli\qodercli.exe
19:59:00  [GlobalDaemon] init rejected: configuration conflict with an in-flight initialization
19:59:07  [GlobalDaemon] init rejected: configuration conflict with an in-flight initialization
19:59:08  [GlobalDaemon] daemon ready
19:59:38  [GlobalDaemon] init rejected: configuration conflict with the ready daemon

2.7 Suggested fix

  • Do not compare the full process.env. Compare only the keys Qoderian sets itself (PATH, QODER_SDK_CUSTOM_BASE_URL_BYOK, QODER_INTEGRATION_ID), or build env from a snapshot that excludes variables added later by other code in the renderer.
  • Alternatively, when the only differences are unrelated env keys, restart the daemon instead of rejecting.
  • It would also help if the error message listed the differing keys. I had to patch main.js locally to find out which field was conflicting.

Expected behavior

  • Do not compare the full process.env. Compare only the keys Qoderian sets itself (PATH, QODER_SDK_CUSTOM_BASE_URL_BYOK, QODER_INTEGRATION_ID), or build env from a snapshot that excludes variables added later by other code in the renderer.
  • Alternatively, when the only differences are unrelated env keys, restart the daemon instead of rejecting.
  • It would also help if the error message listed the differing keys. I had to patch main.js locally to find out which field was conflicting.

Actual behavior

2.8 Workaround

I patched the env comparison in main.js to ignore CLAUDE_AGENT_SDK_VERSION, and disabled Copilot at the same time. New tabs work after that. I did not test the two changes separately.

Claudian has the same pattern (it writes CLAUDE_AGENT_SDK_VERSION from its bundled SDK), so it is likely to trigger the same conflict.

Redacted logs or screenshots

No response

Activity

  1. added
    bug
    on Nov 25, 2026
  2. sorrycc commented on Nov 25, 2026

    @sorrycc
    Contributor

    Thanks for the detailed diagnosis, it was spot on.

    Reproduced against the real SDK (1.0.58) with a dummy CLI: initDaemon(opts), then process.env.CLAUDE_AGENT_SDK_VERSION = '0.3.306', then initDaemon(opts) again → DaemonConfigurationConflictError: Global daemon is already initialized with different options. Without the env write, the second call joins the first initialization.

    Fix in #102: buildDaemonLaunchOptions() now uses a copy of process.env taken the first time it runs, not the live object. Keys that other plugins add later no longer change the daemon options. There's a regression test for it. This issue will close when the PR merges.

    Listing the differing keys in the conflict error would need an SDK change, so that isn't in this PR.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions