fix(tui): stop file-watcher polling for a missing file with a throwing probe#799
Draft
posthog[bot] wants to merge 1 commit into
Draft
fix(tui): stop file-watcher polling for a missing file with a throwing probe#799posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
…g probe The file-watcher's attach-retry loop polled for a not-yet-created file with `fs.accessSync`, which throws ENOENT on every tick while the file is absent. With exception autocapture on, each throw surfaced as a spurious `$exception`, polluting error tracking (~1/sec while the watcher waits for the agent to write `.posthog-events.json`). Swap the throwing `accessSync` existence probe for a non-throwing `fs.existsSync` so the expected "file not there yet" state never raises. `existsSync` returns a boolean without constructing an Error, so there is nothing to capture regardless of how the exception path is wired. Apply the same fix to LogViewer, which uses the identical accessSync-in-retry pattern. Attach the watch before clearing the retry interval so a file removed mid-probe just keeps the poll running. Generated-By: PostHog Code Task-Id: 091f2350-ce0c-4767-bb84-ced895939554
🧙 Wizard CIRun the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands: Test all apps:
Test all apps in a directory:
Test an individual app:
Show more apps
Results will be posted here when complete. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The TUI file-watcher spammed error tracking with expected
ENOENTexceptionswhile waiting for the agent to write
.posthog-events.json.startFileWatcher(src/ui/tui/hooks/file-watcher.ts) can't attachfs.watchto a file that doesn't exist yet, so it falls back to a 1s retry
setIntervalthat probed for the file with
fs.accessSync. That call throwsENOENTonevery tick until the file appears. Because exception autocapture is enabled on
the analytics client, each throw surfaced as a spurious
$exception(
Module.accessSyncunderTimeout._onTimeout), creating error-tracking noise.LogViewer(src/ui/tui/primitives/LogViewer.tsx) used the identicalaccessSync-in-retry pattern.This is error-tracking noise, not a broken flow — the retry loop still works —
but a benign, expected filesystem state should never raise.
Changes
fs.accessSyncexistence probe with a non-throwingfs.existsSyncin both the file-watcher and LogViewer retry loops.existsSyncreturns a boolean without constructing anError, so there isnothing for autocapture to pick up regardless of how the exception path is
wired.
fs.watchbefore clearing the retry interval, so a file removedbetween the existence check and the watch just keeps the poll running for the
next tick instead of dropping the watcher.
accessSyncwhile thefile is absent.
Test plan
pnpm build && pnpm test— 1157 tests pass, including the newnever probes for the missing file with a throwing accessSynccase.pnpm lint— 0 errors (pre-existing warnings only; none in the changed files).Created with PostHog Code from an inbox report.