fix(skills): stop skills updater throwing ENOENT on removed staging dir#3236
Draft
posthog[bot] wants to merge 1 commit into
Draft
fix(skills): stop skills updater throwing ENOENT on removed staging dir#3236posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
The skills auto-updater staged downloads into a shared `<skills>.new` directory and called `readdir` on it with no ENOENT guard. A second workspace-server instance (another window/project) — or the atomic swap `rename` — could remove that shared path mid-run, so `readdir` threw `ENOENT ... scandir '.../skills.new'`, which surfaced as error-tracking noise even though the failure is non-fatal (the updater retries on the next interval and bundled skills keep working). Isolate the staging (and backup) dirs per instance via a stable `runId` (`process.pid`) so a concurrent instance can no longer clobber the path, keeping them on the same filesystem so the atomic-swap `rename` still works. As defense in depth, treat a missing staging dir as an empty/no-op cycle rather than an ENOENT throw at both the validate `readdir` and the swap. Generated-By: PostHog Code Task-Id: 905f1443-bcf1-47a5-b6b8-c7b6cf65ad7e
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
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 desktop app's skills auto-updater (
PosthogPluginService) staged downloads into a shared<appData>/skills.newdirectory and then calledreaddiron it to validate the download — with no ENOENT guard and no per-run isolation. Theupdatingflag only serializes runs within a single process, so a second workspace-server instance (another app window/project) — or the atomic swaprename— could deleteskills.newout from under an in-flight run, and thereaddirblew up withENOENT ... scandir '.../skills.new'.The failure is non-fatal (the updater retries on the next interval and bundled skills keep working), so the real cost was error-tracking noise from an exception that shouldn't be surfaced.
Changes
<skills>.new-<runId>/<skills>.old-<runId>, keyed on a stable per-processrunId(process.pid). Concurrent instances no longer share a path, so they can't clobber each other's staging dir. The dirs stay on the same filesystem as the runtime skills dir, so the atomic-swaprenamestill works, and the stable pid lets thecreate-staging-dirstep self-heal any leftover dir from an interrupted prior run.validate-skillsreaddirand just before the swaprename.How did you test this?
captureException, existing cache preserved, no false "updated" event) — it fails without the fix..newpath is never used and the per-instance staging/backup dirs are cleaned up on success.pnpm --filter @posthog/workspace-server test posthog-plugin→ 40 passing.Automatic notifications
Created with PostHog Code from an inbox report.