fix(gateway): guard interface discovery failures on WSL#44419
fix(gateway): guard interface discovery failures on WSL#44419jmcte wants to merge 2 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR adds defensive Key observations:
Confidence Score: 4/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/gateway/tools-invoke-http.ts
Line: 42-43
Comment:
**Duplicated test-mode detection logic**
The `isTestRun` helper is defined here as a local, unexported function, but an identical expression (`env.NODE_ENV === "test" || parseBooleanValue(env.VITEST) === true`) is independently inlined in `src/plugins/config-state.ts` (lines 142 and 181). If the definition diverges in the future (e.g., a third env variable is added as a test signal), the two copies would need to be updated in sync.
Consider extracting the shared detection to a utility — e.g. `src/utils/is-test-env.ts` — and importing it in both `config-state.ts` and `tools-invoke-http.ts`. That would also make the `env` parameter on `isTestRun` testable without going through the module's internal call sites.
This pattern also appears inline at `src/plugins/config-state.ts:142` and `src/plugins/config-state.ts:181`.
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: b434621 |
b434621 to
767b2c8
Compare
|
Thanks for picking this up and wiring it back to #44180. I reproduced the original WSL2 failure locally ( From a quick pass over the current CI failures, most of the red checks do not appear to be in the files touched here. This PR changes only:
But several reported failures seem to come from other areas (for example auth-profile mocks, outbound/media-local-roots mocks, command-registry initialization, and a TUI gateway port assertion), plus the separate In short: the fix direction here looks right and it lines up with the behavior reported in #44180. |
|
Thanks for picking this up. For attribution and validation context: this issue was originally diagnosed from a real WSL2 machine on my side, where I also re-tested this on the latest I then applied the same source-level fix locally on top of the latest main, rebuilt, and re-verified it with both runtime checks and targeted tests:
Everything passed locally after the guard was added. I also preserved the fix on my fork here in case it helps with follow-up validation or if this PR needs additional evidence: |
Summary
os.networkInterfaces()always succeeds, which can crash on WSL2 withuv_interface_addresseserrorsgateway status,status, tailnet address discovery, and pairing URL resolution right when the system is already in a degraded networking stateChange Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation:Repro + Verification
Environment
src/gateway/net.ts,src/infra/tailnet.ts, andsrc/pairing/setup-code.tsSteps
os.networkInterfaces()throws.Expected
Actual
Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
pnpm exec vitest run src/gateway/net.test.ts src/infra/infra-runtime.test.ts src/pairing/setup-code.test.tsReview Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes)No)No)Failure Recovery (if this breaks)
src/gateway/net.ts,src/infra/tailnet.ts,src/pairing/setup-code.tsand their matching testsRisks and Mitigations