Skip to content

fix(linux-canvas): report degraded socket monitoring - #109502

Merged
steipete merged 1 commit into
openclaw:mainfrom
wahaha1223:fix/linux-canvas-report-watcher-errors
Aug 1, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
wahaha1223:fix/linux-canvas-report-watcher-errors

Conversation

@wahaha1223

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where operators running the Linux Canvas node host received no diagnostic when the desktop socket directory could not be watched. Canvas availability continued through periodic polling, but the loss of immediate filesystem notifications was completely silent.

Why This Change Was Made

The Linux Canvas plugin now reports both synchronous fs.watch() setup failures and asynchronous watcher failures through the public plugin SDK logger, while preserving the existing one-second /proc/net/unix polling fallback and cleanup behavior. This is limited to diagnostics for the existing degraded mode; it does not change Canvas availability policy, IPC behavior, configuration, or protocol shapes.

User Impact

Linux operators can now see when Canvas socket monitoring has degraded to polling and diagnose missing directories, file-descriptor pressure, permission failures, or watcher backend failures without losing the existing fallback behavior.

Evidence

Real-machine before / premise / after / negative control

Environment: Linux x86_64, Node v24.18.0. The same exported production function was run on a real Linux filesystem from a detached latest-main worktree and the fixed worktree. A deliberately absent socket parent directory makes the operating system return a real ENOENT from fs.watch(); no filesystem API was mocked or replaced.

node --import tsx --input-type=module -e 'import os from "node:os"; import path from "node:path"; import { watchLinuxCanvasSocket } from "./extensions/linux-canvas/src/socket-path.ts"; const socketPath = path.join(os.tmpdir(), `openclaw-missing-watch-${process.pid}`, "canvas.sock"); console.log(`PROOF socket_parent_exists=false path=${socketPath}`); const stop = watchLinuxCanvasSocket(socketPath, () => console.log("unexpected-change")); stop(); console.log("PROOF returned_cleanup_without_throw=true");'

Negative control / before (upstream/main at 510cf463300e596204738b7b1a62f56520306696):

PROOF socket_parent_exists=false path=/tmp/openclaw-missing-watch-521001/canvas.sock
PROOF returned_cleanup_without_throw=true

The real fs.watch() failure is swallowed without any diagnostic. The cleanup contract still returns and does not throw.

Premise: Node documents that fs.watch() may throw when its underlying watcher is unavailable and that an FSWatcher is no longer usable after it emits error: https://nodejs.org/api/fs.html#fswatchfilename-options-listener. The production caller already starts a one-second /proc/net/unix reconciliation timer after watchLinuxCanvasSocket() returns, so reporting the degraded state preserves the existing recovery owner instead of adding a second watcher or retry loop.

After (65e9414eb60516f5995a9c6bd9c085d2a1bf8018):

PROOF socket_parent_exists=false path=/tmp/openclaw-missing-watch-521012/canvas.sock
[linux-canvas] linux canvas socket watcher unavailable for /tmp/openclaw-missing-watch-521012; continuing with availability polling: Error: ENOENT: no such file or directory, watch '/tmp/openclaw-missing-watch-521012'
PROOF returned_cleanup_without_throw=true

The same real failure is now observable and explicitly names the active polling fallback, while the production function keeps its non-throwing cleanup behavior. The regression test separately drives the asynchronous FSWatcher.error contract and verifies that it is reported too.

Focused validation:

node scripts/run-vitest.mjs extensions/linux-canvas
Test Files  3 passed (3)
Tests       18 passed (18)

./node_modules/.bin/oxfmt --check extensions/linux-canvas/src/socket-path.ts extensions/linux-canvas/src/socket-path.test.ts
All matched files use the correct format.

./node_modules/.bin/oxlint extensions/linux-canvas/src/socket-path.ts extensions/linux-canvas/src/socket-path.test.ts
exit 0

git diff --check upstream/main...HEAD
exit 0

Full build and full typecheck were not run locally; fork GitHub Actions are expected to cover the wider repository gates. The Linux desktop Canvas UI was not exercised because this is a non-visual node-host diagnostic change; the affected production watcher path itself was exercised on a real Linux filesystem.

AI-assisted: Yes. I reviewed the complete watcher caller and cleanup path, the polling fallback, sibling watcher error handling, the public plugin SDK logger implementation, adjacent tests, Node's watcher contract, and the real-machine evidence.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Jul 17, 2026
@clawsweeper

clawsweeper Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 3:30 AM ET / 07:30 UTC.

ClawSweeper review

What this changes

The PR adds Linux Canvas operator warnings for synchronous and asynchronous socket-directory watcher failures while retaining the existing polling-based availability fallback.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This PR remains necessary: current main still swallows both setup-time and asynchronous Linux Canvas socket-watcher failures, leaving degraded monitoring silent. The branch reports that degraded mode at the watcher owner while preserving the existing polling reconciliation and cleanup; no actionable patch defect was found.

Priority: P2
Reviewed head: e9526ed31df45c76021dfb3ce8719c74cee8bd52

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong direct Linux proof and focused regression coverage support a clean, narrowly scoped patch; only routine exact-head hosted gates remain.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body shows a real Linux filesystem ENOENT before/after run, and the maintainer comment independently verifies the failure, warning, polling fallback, and cleanup behavior; no private data is exposed in the supplied evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body shows a real Linux filesystem ENOENT before/after run, and the maintainer comment independently verifies the failure, warning, polling fallback, and cleanup behavior; no private data is exposed in the supplied evidence.
Evidence reviewed 7 items Current-main defect: Current main attaches a no-op asynchronous watcher error listener and returns a no-op cleanup when fs.watch() throws, so neither failure mode reaches an operator-visible diagnostic.
Existing recovery owner: The command registration always starts one-second reconciliation after watchLinuxCanvasSocket() returns and closes both the timer and watcher during shutdown; the PR does not add a competing retry or fallback path.
Branch repair: The PR routes both the FSWatcher error event and synchronous fs.watch() exceptions through one logger helper, then keeps the prior non-throwing cleanup contract.
Findings None None.
Security None None.

How this fits together

The bundled Linux Canvas plugin exposes node-host Canvas commands whose availability depends on a local Unix socket. Filesystem watching gives prompt change notifications, while /proc/net/unix polling remains the liveness fallback that ultimately updates command availability.

flowchart LR
  A[Linux Canvas socket directory] --> B[Filesystem watcher]
  B --> C{Watcher failure?}
  C -- No --> D[Availability change callback]
  C -- Yes --> E[Operator warning]
  E --> F[One-second liveness polling]
  F --> G[Canvas command availability]
  D --> G
Loading

Before merge

  • Resolve merge risk (P1) - The supplied latest-head check snapshot still has hosted build, lint, dependency, and contract jobs in progress; merge should wait for the normal exact-head gates to finish successfully.
  • Complete next step (P2) - No repair lane is needed: the proposed branch is a focused, apparently correct repair with no actionable review finding; routine maintainer merge review and exact-head gates remain.
Agent review details

Security

None.

PR surface

Source +10, Tests +36. Total +46 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 12 2 +10
Tests 1 38 2 +36
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 50 4 +46

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Merge this focused owner-boundary repair after the current-head hosted gates complete, retaining the one-second polling reconciliation as the sole availability fallback.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Merge this focused owner-boundary repair after the current-head hosted gates complete, retaining the one-second polling reconciliation as the sole availability fallback.

Do we have a high-confidence way to reproduce the issue?

Yes. A missing socket parent makes fs.watch() throw, and current main catches that exception without logging; the supplied maintainer verification independently exercised this real Linux path and the same source path remains on current main.

Is this the best way to solve the issue?

Yes. Logging at the watcher owner is the narrowest maintainable repair because the caller already owns the polling fallback and shutdown lifecycle; adding retries or diagnostics there would duplicate recovery policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against edfeec49e7a7.

Labels

Label justifications:

  • P2: Silent degraded monitoring affects Linux Canvas operators but preserves Canvas availability through the existing polling fallback.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body shows a real Linux filesystem ENOENT before/after run, and the maintainer comment independently verifies the failure, warning, polling fallback, and cleanup behavior; no private data is exposed in the supplied evidence.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body shows a real Linux filesystem ENOENT before/after run, and the maintainer comment independently verifies the failure, warning, polling fallback, and cleanup behavior; no private data is exposed in the supplied evidence.

Evidence

What I checked:

  • Current-main defect: Current main attaches a no-op asynchronous watcher error listener and returns a no-op cleanup when fs.watch() throws, so neither failure mode reaches an operator-visible diagnostic. (extensions/linux-canvas/src/socket-path.ts:38, edfeec49e7a7)
  • Existing recovery owner: The command registration always starts one-second reconciliation after watchLinuxCanvasSocket() returns and closes both the timer and watcher during shutdown; the PR does not add a competing retry or fallback path. (extensions/linux-canvas/src/commands.ts:176, edfeec49e7a7)
  • Branch repair: The PR routes both the FSWatcher error event and synchronous fs.watch() exceptions through one logger helper, then keeps the prior non-throwing cleanup contract. (extensions/linux-canvas/src/socket-path.ts:47, e9526ed31df4)
  • Dependency contract: Installed Node type declarations define FSWatcher with an error event carrying an Error, and fs.watch() returns that watcher type; handling both creation exceptions and emitted errors matches the API surface.
  • Real behavior and focused validation: The PR body includes a real Linux missing-directory before/after run, and the maintainer comment independently reports the same ENOENT path plus the caller's polling and cleanup boundary. The supplied checks also show focused and security gates passing, with remaining hosted checks still running on the latest head. (extensions/linux-canvas/src/socket-path.test.ts:50, e9526ed31df4)
  • Feature provenance: Blame attributes the current watcher implementation to a recent Linux Canvas source update; earlier available history identifies the original Canvas implementation and refactor work by Peter Steinberger. (extensions/linux-canvas/src/socket-path.ts:29, 42c313976ef0)

Likely related people:

  • steipete: Peter Steinberger authored the available Linux Canvas implementation and internal-refactor commits, and independently verified the watcher failure and fallback boundary in the PR discussion. (role: original feature contributor and recent verifier; confidence: high; commits: b363d5a29328, 75d029dae2e5; files: extensions/linux-canvas/src/socket-path.ts, extensions/linux-canvas/src/commands.ts)
  • Vincent Koc: Current-line blame attributes the present watcher implementation to this recent source update, making Vincent Koc a useful routing contact for the current code shape. (role: recent area contributor; confidence: medium; commits: 42c313976ef0; files: extensions/linux-canvas/src/socket-path.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Wait for the currently in-progress exact-head hosted checks to finish before merging.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-07-17T01:36:27.534Z sha 65e9414eb60516f5995a9c6bd9c085d2a1bf8018 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-31T05:56:25.021Z sha 65e9414eb60516f5995a9c6bd9c085d2a1bf8018 :: needs maintainer review before merge. :: none

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 31, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Jul 31, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Aug 1, 2026
@steipete

steipete commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer verification for contributor-authored head e9526ed31df45c76021dfb3ce8719c74cee8bd52:

  • Independently reproduced the defect on current main with real node:fs: watching a nonexistent Canvas runtime directory throws ENOENT, but watchLinuxCanvasSocket swallowed it without any operator-visible warning.
  • Ran the same real missing-directory watcher through this exact PR head: it emits linux canvas socket watcher unavailable ... continuing with availability polling: Error: ENOENT and preserves safe cleanup.
  • Exercised the actual createLinuxCanvasCommands boundary: existing one-second polling still discovers availability, and shutdown closes its transport.
  • node scripts/run-vitest.mjs extensions/linux-canvas/src/socket-path.test.ts passed on the exact refreshed head; the contributor regression covers synchronous EMFILE and asynchronous ENOSPC. The existing Linux-only socket case is skipped on macOS.
  • Fresh structured review on this exact head passed with --mode branch --base origin/main --engine codex --thinking xhigh; zero accepted/actionable findings.
  • The original July 17 branch could no longer pass today's required dependency audit because six HIGH advisories were disclosed after its previous green run. Refreshed the original contributor branch onto current main without changing the fix: author remains wahaha1223; stable production/test patch-id remains 08071310f53299a486ec404b63a67698d3442a6a.
  • Exact refreshed-head full hosted CI: https://github.com/openclaw/openclaw/actions/runs/30689699122

@steipete
steipete force-pushed the fix/linux-canvas-report-watcher-errors branch from 65e9414 to e9526ed Compare August 1, 2026 07:25
@steipete
steipete merged commit dccb1b9 into openclaw:main Aug 1, 2026
85 checks passed
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 1, 2026
* origin/main: (41 commits)
  test(ci): update memory helper routing expectation (#117295)
  fix(canvas): emit successful control results in JSON mode (#117297)
  fix(imessage): settle native inbound reply delivery (#117282)
  fix(agents): reject invalid UTF-8 LSP responses (#117271)
  fix(line): centralize card and template message alt text (#117280)
  fix(release): validate candidates before Docker publication (#117252)
  fix(media): validate provider-owned generated media downloads (#117281)
  fix(feishu): restore custom HTTPS API domains (#117278)
  fix(models): reuse prepared plugin metadata (#117131)
  fix(agents): stop fallback after delivered-but-failed attempts (#114628)
  fix(memory): reuse targeted session corpus snapshot (#117247)
  fix(matrix): reconcile durable sends after response loss
  test(release): repair full validation regressions (#116931)
  fix(linux-canvas): report socket watcher fallback (#109502)
  fix(codex): preserve authoritative turn completion (#117185)
  fix(canvas): preserve widgets across derived-name collisions (#117132)
  fix(channels): config validation rejects documented channels.<id>.configWrites on 13 channels (#117206)
  fix(msteams): prevent duplicate final replies (#116398)
  fix(doctor): session SQLite restore installs an empty session index over the valid archive (#117221)
  fix(plugins): preserve workspace plugins across CLI and control UI (#117265)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* origin/main: (41 commits)
  test(ci): update memory helper routing expectation (openclaw#117295)
  fix(canvas): emit successful control results in JSON mode (openclaw#117297)
  fix(imessage): settle native inbound reply delivery (openclaw#117282)
  fix(agents): reject invalid UTF-8 LSP responses (openclaw#117271)
  fix(line): centralize card and template message alt text (openclaw#117280)
  fix(release): validate candidates before Docker publication (openclaw#117252)
  fix(media): validate provider-owned generated media downloads (openclaw#117281)
  fix(feishu): restore custom HTTPS API domains (openclaw#117278)
  fix(models): reuse prepared plugin metadata (openclaw#117131)
  fix(agents): stop fallback after delivered-but-failed attempts (openclaw#114628)
  fix(memory): reuse targeted session corpus snapshot (openclaw#117247)
  fix(matrix): reconcile durable sends after response loss
  test(release): repair full validation regressions (openclaw#116931)
  fix(linux-canvas): report socket watcher fallback (openclaw#109502)
  fix(codex): preserve authoritative turn completion (openclaw#117185)
  fix(canvas): preserve widgets across derived-name collisions (openclaw#117132)
  fix(channels): config validation rejects documented channels.<id>.configWrites on 13 channels (openclaw#117206)
  fix(msteams): prevent duplicate final replies (openclaw#116398)
  fix(doctor): session SQLite restore installs an empty session index over the valid archive (openclaw#117221)
  fix(plugins): preserve workspace plugins across CLI and control UI (openclaw#117265)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: linux P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants