ops: show broker connection in baudbot status#101
Conversation
Greptile SummaryAdded broker connection status reporting to Confidence Score: 4/5
Important Files Changed
Last reviewed commit: b19343c |
| function persistBrokerHealth() { | ||
| brokerHealth.updated_at = new Date().toISOString(); | ||
| const dir = path.dirname(BROKER_HEALTH_PATH); | ||
| const tmp = `${BROKER_HEALTH_PATH}.tmp`; | ||
| fs.mkdirSync(dir, { recursive: true }); | ||
| fs.writeFileSync(tmp, `${JSON.stringify(brokerHealth, null, 2)}\n`, { mode: 0o600 }); | ||
| fs.renameSync(tmp, BROKER_HEALTH_PATH); | ||
| } |
There was a problem hiding this comment.
Bug: The persistBrokerHealth function uses synchronous file I/O operations like fs.mkdirSync and fs.writeFileSync without try...catch blocks, which can crash the process.
Severity: CRITICAL
Suggested Fix
Wrap the synchronous file system operations within the persistBrokerHealth function in a try...catch block. Log any errors that occur instead of allowing them to crash the process. This will make the health persistence mechanism more resilient to transient or persistent filesystem issues.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: slack-bridge/broker-bridge.mjs#L135-L142
Potential issue: The `persistBrokerHealth()` function performs synchronous file I/O
operations (`fs.mkdirSync`, `fs.writeFileSync`, `fs.renameSync`) without any error
handling. This function is called frequently from multiple critical paths, including at
startup and within error handling blocks of the main poll loop. A filesystem error, such
as a full disk or permission issue, will throw an unhandled exception, causing the
entire bridge process to crash and leading to a service outage.
Summary
baudbot statusValidation
bash -n bin/baudbotnpm run test:shelllocally, butvitestwas not available in PATH in this environment