fix(MESHCENT-002-2): CU-86akn96pm desktopLock throws inside switch instead of proper error signaling and lacks try/catch around child process calls - #151
Conversation
…er error signaling and lacks try/catch around child process calls
| child.waitExit(); | ||
| if (child.stderr.str != '') { throw ('Failed'); } | ||
| break; | ||
| case 'darwin': |
There was a problem hiding this comment.
🦩 🔴 desktopLock throws inside switch instead of proper error signaling and lacks try/catch around child process calls
In desktopLock.lock() (modules/desktop-lock.js), wrapped the entire switch statement in a try/catch block so any thrown value or exception from the child_process calls (execFile, waitExit, stdin/stdout handling) is caught; replaced the bare string throws ('Failed' and 'Not supported on ' + process.platform) with proper new Error(...) objects, and the catch handler re-throws as an Error object (wrapping non-Error values) to guarantee consistent error signaling for any caller up the chain. This does not add ws.send-based error reporting since this module has no access to a ws connection object — a complete fix per the stated convention would require the calling module (the one that invokes desktop-lock.lock() from a ws message handler) to wrap the call in its own try/catch and emit an error response over the websocket; that caller code is outside this file's scope and was not provided.
🤖 Prompt for AI agents
In modules/desktop-lock.js around line 36, review and complete this code-review fix: desktopLock throws inside switch instead of proper error signaling and lacks try/catch around child process calls.
What the draft fix changed: In `desktopLock.lock()` (modules/desktop-lock.js), wrapped the entire switch statement in a try/catch block so any thrown value or exception from the child_process calls (execFile, waitExit, stdin/stdout handling) is caught; replaced the bare string throws ('Failed' and 'Not supported on ' + process.platform) with proper `new Error(...)` objects, and the catch handler re-throws as an Error object (wrapping non-Error values) to guarantee consistent error signaling for any caller up the chain. This does not add ws.send-based error reporting since this module has no access to a ws connection object — a complete fix per the stated convention would require the calling module (the one that invokes `desktop-lock`.lock() from a ws message handler) to wrap the call in its own try/catch and emit an error response over the websocket; that caller code is outside this file's scope and was not provided.
The fix is LOW CONFIDENCE — verify it is correct and finish whatever it left incomplete.
fix confidence: 🔴 55 low — review closely — react 👍/👎 to teach the reviewer
Closes findings from rule MESHCENT-002-2 — desktopLock throws inside switch instead of proper error signaling and lacks try/catch around child process calls.
Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.
modules/desktop-lock.js:36What changed — and what was deliberately left — is explained per finding as inline review comments on the lines each finding touched.
Run: https://product-hub.flamingo.so/admin/code-review
Run id:
06986371-2b8e-4388-aee4-5d1dc04f8838Merging this PR is recorded as acceptance of the rule that produced it;
closing it unmerged is recorded as rejection. Both feed rule health, so
closing a wrong suggestion is useful rather than merely tidy.
ClickUp task: CU-86akn96pm MeshAgent review findings sweep (12 PRs)