Summary
When mermaid + jsdom are resolvable at runtime, openwiki activates its Mermaid rendering path, which installs jsdom's browser globals (window, document, navigator, …) into the Node process. The Anthropic SDK then detects a "browser-like environment" and refuses to construct the client, aborting the whole run with exit code 1 — before any docs are generated.
This makes Mermaid support and the Anthropic/Vertex model client mutually exclusive as currently wired.
Environment
- openwiki fork tag:
v0.1.1-vertex.1 (mediwareinc/openwiki, code --update)
- Provider:
OPENWIKI_PROVIDER=gemini-enterprise (Claude on Vertex via the Anthropic Vertex SDK, ADC auth)
- Model:
claude-opus-4-8, GOOGLE_CLOUD_LOCATION=global
- Runner: GitHub Actions
ubuntu-latest, Node 22
- Command:
node dist/cli.js code --update --recursive --print
mermaid + jsdom installed alongside the built CLI (pnpm add mermaid jsdom)
Error
It looks like you're running in a browser-like environment.
This is disabled by default, as it risks exposing your secret API credentials to attackers.
If you understand the risks and have appropriate mitigations in place,
you can set the `dangerouslyAllowBrowser` option to `true`, e.g.,
new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
##[error]Process completed with exit code 1.
Root cause (chain)
mermaid + jsdom resolve → openwiki enables the Mermaid code path.
- That path defines jsdom browser globals (
window, document, …) process-wide, at startup.
- The Anthropic SDK constructor checks for
window/document, concludes it's a browser, and throws unless dangerouslyAllowBrowser: true.
- Because the globals are set before/around client construction, the model client can never be built → run dies.
The mermaid-only piece is fine; it's jsdom's global leakage colliding with the SDK's browser guard.
Suggested fixes (either, ideally both)
- Construct the Anthropic client with
dangerouslyAllowBrowser: true. openwiki runs in a CLI/CI Node process, not a real browser — the guard is a false positive here, and no credential is exposed to an untrusted page. This is the standard escape hatch for server/CLI code that pulls in DOM shims.
- Scope the jsdom globals to only the Mermaid render call (create the
JSDOM instance and pass its window/document locally, or set/tear down globals around just the render) instead of assigning them globally at startup. This avoids polluting the environment the SDK inspects.
Fix #1 is the smaller change and unblocks immediately; fix #2 is the cleaner long-term shape.
Impact / workaround
Until fixed, enabling Mermaid (installing jsdom) breaks the Vertex-backed run entirely. Current workaround is to not install mermaid/jsdom — which disables diagrams but keeps code --update --recursive working.
Repro
- Build the fork at
v0.1.1-vertex.1.
pnpm add mermaid jsdom into the CLI dir.
- Run
node dist/cli.js code --update --recursive --print with OPENWIKI_PROVIDER=gemini-enterprise and Vertex ADC.
- Observe the browser-environment error above.
Failing run for reference: mediwareinc/Meridian.IMR Actions run 29974928100 (step "Run openwiki --update").
Summary
When
mermaid+jsdomare resolvable at runtime, openwiki activates its Mermaid rendering path, which installs jsdom's browser globals (window,document,navigator, …) into the Node process. The Anthropic SDK then detects a "browser-like environment" and refuses to construct the client, aborting the whole run with exit code 1 — before any docs are generated.This makes Mermaid support and the Anthropic/Vertex model client mutually exclusive as currently wired.
Environment
v0.1.1-vertex.1(mediwareinc/openwiki,code --update)OPENWIKI_PROVIDER=gemini-enterprise(Claude on Vertex via the Anthropic Vertex SDK, ADC auth)claude-opus-4-8,GOOGLE_CLOUD_LOCATION=globalubuntu-latest, Node 22node dist/cli.js code --update --recursive --printmermaid+jsdominstalled alongside the built CLI (pnpm add mermaid jsdom)Error
Root cause (chain)
mermaid+jsdomresolve → openwiki enables the Mermaid code path.window,document, …) process-wide, at startup.window/document, concludes it's a browser, and throws unlessdangerouslyAllowBrowser: true.The
mermaid-only piece is fine; it's jsdom's global leakage colliding with the SDK's browser guard.Suggested fixes (either, ideally both)
dangerouslyAllowBrowser: true. openwiki runs in a CLI/CI Node process, not a real browser — the guard is a false positive here, and no credential is exposed to an untrusted page. This is the standard escape hatch for server/CLI code that pulls in DOM shims.JSDOMinstance and pass itswindow/documentlocally, or set/tear down globals around just the render) instead of assigning them globally at startup. This avoids polluting the environment the SDK inspects.Fix #1 is the smaller change and unblocks immediately; fix #2 is the cleaner long-term shape.
Impact / workaround
Until fixed, enabling Mermaid (installing jsdom) breaks the Vertex-backed run entirely. Current workaround is to not install
mermaid/jsdom— which disables diagrams but keepscode --update --recursiveworking.Repro
v0.1.1-vertex.1.pnpm add mermaid jsdominto the CLI dir.node dist/cli.js code --update --recursive --printwithOPENWIKI_PROVIDER=gemini-enterpriseand Vertex ADC.Failing run for reference: mediwareinc/Meridian.IMR Actions run 29974928100 (step "Run openwiki --update").