Repository navigation
fix(desktop): survive slow first launch of downloaded postgres - #293
Merged
Merged
Conversation
macOS checks each newly written executable on its first launch. A cold `postgres --version` took 3-3.6 s on an idle Mac; on a freshly installed, busy Mac it went past the old 10 s limit per binary and failed with a generic error. Each retry extracts new files, so it pays the cost again. - Run the three `--version` checks in one hard 3 min budget, with a "Checking PostgreSQL with macOS security…" status after 5 s. - SIGKILL on timeout. Waiting for the exit and the output is bounded too, so a retry cannot hang. - Name the cause (timeout, blocked by the OS, failed run, wrong version) and log the binary, exit code or signal, the timeout, the timing and trimmed stdout/stderr. - Remove com.apple.quarantine from the verified, extracted runtime. A quarantined binary waited in syspolicyd until killed. - Drop Electron's IPC prefix from setup errors. Fixes: #23
This was referenced Nov 13, 2026
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.
Evidence
A colleague ran nightly
0.2.0-nightly.92on a fresh MacBook Pro (M5 Pro, macOS 27.0.1). The first local setup failed twice withDownloaded PostgreSQL could not run on this computer. The desktop log had only that generic line. "Try again" sometimes looked stuck on "Setting up PostgreSQL…". The 7th attempt worked, andinitdb, postgres, migrations, gateway and worker then started normally.Measured on a Mac Studio, macOS 27.0.1, idle, using the installer's own steps in a temp dir (real npm download, SHA-512, extract,
preparePostgres,--version):postgrespg_ctlinitdbcom.apple.quarantineUnable to initialize qtn_procevery 2 sxattr -drFiles extracted by Canopy carry only
com.apple.provenance, not quarantine.preparePostgres(thin plus ad-hoc signing of 113 Mach-O files) takes 4.4–5 s.Root cause
macOS checks each newly written executable on its first launch, and the slow part is
postgres, which loads ICU, OpenSSL and libxml2. The cost depends on the files, not their content: every retry extracts a new runtime and pays it again. The smoke check gave each binary a fixed 10 sAbortSignal.timeout. On a freshly installed, busy Mac that first launch went past 10 s. Any timeout or kill turned into the same generic error, with no detail in the log. Later attempts passed once the Mac was less busy, not because of a cache.Fix
postgres-check.ts: the three--versionchecks share one hard budget of 3 min. After 5 s the setup screen shows "Checking PostgreSQL with macOS security… This can take a minute the first time."logs/desktop.loggets the binary, the exit code or signal, whether the timeout fired, the elapsed time, and trimmed stdout/stderr with the runtime path replaced by<runtime>. A successful install logs the first-launch times.preparePostgresremovescom.apple.quarantinefrom the extracted runtime. Integrity still comes from the pinned SHA-512, checked before extraction.package.tgz.partial; a test now covers it, and that noextracted/orinstall/directory is left after a failure.Error invoking remote method 'canopy:configure': Error:prefix.PG*orDYLD*, Postgres uses a random port on127.0.0.1with no Unix socket (-k ""), and it has its own data dir. Documented indocs/desktop.md.Fixes: #23: #23 moved PostgreSQL from the signed bundle to a runtime download, which runs freshly written binaries through the 10 s check.Tests
apps/desktop/test/postgres-check.test.tsuses an injectable spawn and short budgets:bun install,gen:check,typecheck,lint,format:check,check:tmp(1530 pass, 0 fail) and the web build are all clean.Not verified
Copy audit (docs/copy.md §8)
Downloaded PostgreSQL could not run on this computer. Check the desktop logs and OS security policy, then try again.(every failure)PostgreSQL did not respond within 3 min. macOS may still be checking it for security. Try again.macOS stopped PostgreSQL from running. Check System Settings → Privacy & Security, then try again.(other OS:Your computer stopped PostgreSQL from running. Check your security software, then try again.)Downloaded PostgreSQL reports an unexpected version. Try again.Downloaded PostgreSQL could not run on this computer. Check the desktop logs, then try again.Checking PostgreSQL with macOS security… This can take a minute the first time.(other OS:Checking PostgreSQL… This can take a minute the first time.)Error invoking remote method 'canopy:configure': Error: ……Checks: sentence case; each error ends with an action; no paths or jargon; no humour in errors; sentences ≤ 20 words. Glossary: no new terms. The texts sit in the existing startup alert and status line, so the layout is unchanged.