fix(gateway): handshake timeout + token-only scope grant (#47103, #48167)#47388
fix(gateway): handshake timeout + token-only scope grant (#47103, #48167)#47388haoruilee wants to merge 8 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR restores The change is minimal and well-scoped:
Confidence Score: 5/5
Last reviewed commit: 3ec248f |
- openclaw#47391 fix(whatsapp): restore config-driven block streaming for WhatsApp delivery - openclaw#47388 fix(gateway): restore handshake timeout to 10s to fix devices list on slow systems, solve openclaw#47103
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ccb1a19b42
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
extensions/whatsapp/src/monitor-inbox.allows-messages-from-senders-allowfrom-list.test.ts
Outdated
Show resolved
Hide resolved
6ca10cc to
01c94c1
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 01c94c1adb
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7c33138d26
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
… slow systems (openclaw#47103) Co-authored-by: 0x4C33 <[email protected]>
a9c7146 to
4d413b7
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4d413b78eb
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
The previous condition cleared scopes for all device-less non-control-ui connections because !isControlUi made the OR always true. Split logic: clear on non-allow; normalize to operator.read only for allow + token/password.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 94084a2549
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // Allow sufficient time for CLI to load device identity, sign the connect payload, | ||
| // and complete the handshake on slow systems (cold start, disk I/O). Too short causes | ||
| // premature close with "gateway closed (1000 normal closure)" before connect completes. | ||
| export const DEFAULT_HANDSHAKE_TIMEOUT_MS = 10_000; |
There was a problem hiding this comment.
Raise probe client budgets with the longer handshake timeout
On hosts where the WebSocket handshake takes more than ~800ms–5s, this change still leaves the status/probe flows timing out before the server’s new 10s window is useful. I checked src/commands/gateway-status/helpers.ts:119-127 and src/commands/status.scan.shared.ts:73-78: both cap probeGateway() well below 10s (800ms for local gateway status, 2.5s/5s for status), so the same slow machines that motivated this change will still fail those commands even though callGateway-based paths like devices list now get longer on the server side.
Useful? React with 👍 / 👎.
Summary
Describe the problem and fix in 2–5 bullets:
openclaw devices listandopenclaw devices approvefail on 2026.3.12+ withgateway closed (1000 normal closure): no close reason. Separately, CLI and Dashboard using static token auth getmissing scope: operator.read— token connects but receives zero scopes.DEFAULT_HANDSHAKE_TIMEOUT_MSfrom 3 seconds to 10 seconds so the CLI has enough time to complete the handshake. (2) Grantoperator.readfor device-less token/password auth so read RPCs work instead of clearing scopes to zero.MAX_PREAUTH_PAYLOAD_BYTES, preauth payload size checks, andsetSocketMaxPayloadafter connect. Admin methods still requireoperator.admin.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
operator.readscope soopenclaw devices list,openclaw status,gateway probe, and Dashboard read operations work. No config changes.Security Impact (required)
Yes, explain risk + mitigation: N/ARepro + Verification
Environment
gateway.bind=loopback, token auth for scope fixSteps
openclaw gateway runor via app)openclaw devices listoropenclaw devices list --token DASHBOARD_TOKENopenclaw gateway probeExpected
Devices list (or empty list) and probe succeed without error.
Actual
gateway closed (1000 normal closure): no close reasonmissing scope: operator.readEvidence
Attach at least one:
pnpm test src/gateway/server.preauth-hardening.test.tspasses (uses env override for short timeout).pnpm test src/gateway/server.auth.compat-baseline.test.tsandserver.auth.default-token.test.tspass. Manual repro:openclaw devices listsucceeds after the fix.Human Verification (required)
pnpm checkpasses.operator.admin.Review Conversations
Compatibility / Migration
Failure Recovery (if this breaks)
OPENCLAW_TEST_HANDSHAKE_TIMEOUT_MS(test-only; no production override).src/gateway/server-constants.ts,src/gateway/server/ws-connection/message-handler.tsRisks and Mitigations
operator.readinstead of zero scopes.operator.admin.