fix(code): unblock main thread by decompressing skills zips off-thread#2242
Merged
Merged
Conversation
PosthogPluginService runs updateSkills() during app startup, which calls fflate.unzipSync on the downloaded skills + context-mill archives. Pure-JS sync decompression on the Electron main thread pegged CrBrowserMain for tens of seconds on launch, surfacing as an app-hang for users on v0.52.0. Swap to fflate's async unzip via a small unzipAsync promisify helper in extract-zip.ts, used by both extractZip and the inner omnibus-zip path in update-skills-saga.ts. Async unzip yields the event loop so the main thread stays responsive during extraction. Build-time scripts (vite.main.config.mts, scripts/pull-skills.mjs) keep unzipSync — they don't run in the Electron app. Generated-By: PostHog Code Task-Id: 0270afde-6140-4867-bd57-52ae8a767a4d
Contributor
|
Reviews (1): Last reviewed commit: "fix(code): unblock main thread by decomp..." | Re-trigger Greptile |
andrewm4894
approved these changes
May 20, 2026
Member
andrewm4894
left a comment
There was a problem hiding this comment.
was just looking into this too when doing local dev for some inbox stuff
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.
Summary
PosthogPluginService.updateSkills()runs during startup and callsfflate.unzipSyncon the downloaded skills + context-mill archives. Pure-JS sync decompression on the Electron main thread peggedCrBrowserMainfor tens of seconds on launch, surfacing as an app-hang for users on v0.52.0 (Unresponsive for 81 seconds before samplingin the crash log).unzipvia a smallunzipAsyncpromisify helper inextract-zip.ts. Used by bothextractZipand the inner omnibus-zip path inupdate-skills-saga.ts. Async unzip yields the event loop so the main thread stays responsive during extraction.vite.main.config.mts,scripts/pull-skills.mjs) keepunzipSync— they don't run in the Electron app.Root cause (from the crash log)
Main thread stuck at
node::fs::FileHandle::CloseReq::Resolve→ V8 → JIT'd JS for all 41/41 samples — the promise continuation right afterawait readFile(zipPath)resolves, which is exactly whereunzipSyncran. All 4libuv-workerthreads parked inuv_cond_wait, confirming the hang was pure CPU on the main thread, not I/O. 1.3 GB footprint matched the fully-materialized decompressed zip held in memory.Test plan
pnpm --filter code typecheckcleanpnpm --filter code test— all 1348 tests pass (one mock updated fromunzipSyncto asyncunzip)Generated-By: PostHog Code
Task-Id: 0270afde-6140-4867-bd57-52ae8a767a4d