Dashboard › cli › Distillation
3be3d7e8-96d6-4d8f-b395-e8e1d85bbd49["lore_tm_v1_EYfpNF1ytXf_d06MzUESKdpj5-RjgD9Boc0DV7mfEnk"]
/home/byk/.local/share/opencode/worktree/0e8c2f3bbe145a3280d6fb6ed900a5121f382cf0/toolkit-bridge-upgrade/packages/cli/src/lib/upgrade.ts, totaling exactly 1144 lines.getNightlyGzFilename() returns ${getPlatformBinaryName()}.gz; nightly layers use that value as the org.opencontainers.image.title annotation, including sentry-windows-x64.exe.gz on Windows.downloadNightlyToPath() gets an anonymous GHCR token, fetches nightly-${version} when a version is supplied or the rolling :nightly manifest otherwise, finds the platform .gz layer, downloads its blob, and streams decompression to destPath; a response without a body throws UpgradeError("execution_failed", "GHCR blob response had no body").downloadStableToPath() first tries ${url}.gz (documented as approximately 37 MB versus 99 MB and approximately 60% smaller), streams successful gzip responses through streamDecompressToFile(), and silently falls back on any gzip failure to the raw GitHub Release binary.UpgradeError("execution_failed", \Failed to download binary: HTTP ${response.status}`)for non-OK responses, fully consumes the response withresponse.arrayBuffer(), then calls writeFile(destPath, new Uint8Array(body)); this avoids a Bun event-loop bug where Bun.write(path, Response) can exit before a large streaming download completes (https://github.com/oven-sh/bun/issues/13237`).VERIFY_MAX_ATTEMPTS = 6 and VERIFY_BASE_DELAY_MS = 100; probeBinaryFile(path) returns the size only when statSync(path, { throwIfNoEntry: false }) reports a regular file with stats.size > 0, otherwise null.waitForBinaryVisible() addresses Windows + Bun 1.3.9 issue CLI-1D3, where Bun.file().writer().end() can return before the OS exposes the file and a subsequent Bun.spawn fails with Executable not found in $PATH.waitForBinaryVisible() performs exponential-backoff probes in this exact sequence: 1. probe at 0 ms, sleep 100 ms; 2. probe at 100 ms, sleep 200 ms; 3. probe at 300 ms, sleep 400 ms; 4. probe at 700 ms, sleep 800 ms; 5. probe at 1500 ms, sleep 1600 ms; 6. final probe at 3100 ms with no sleep.waitForBinaryVisible() throws when the downloaded file “never becomes visible or stays empty”; the exact failure is UpgradeError("execution_failed", \Downloaded binary is missing or empty at ${path}. This is usually transient — rerun `sentry cli upgrade` to retry.`)`.Binary became visible after ${attempt} attempts, each retry logs the path, delay, and ${attempt}/${VERIFY_MAX_ATTEMPTS}, and successful verification logs Binary verified (${formatBytes(verifiedSize)}).downloadBinaryToTemp() acquires the lock from getCurlInstallPaths(), best-effort deletes a leftover tempPath, tries tryDeltaUpgrade() first, and retains deltaResult.patchBytes when delta succeeds.downloadBinaryToTemp() behavior after delta failure: explicit offline mode throws offline_cache_miss directing the user to rerun sentry cli upgrade without --offline; implicit offline mode throws offline_cache_miss stating the network is unavailable and recommending checking the connection; online mode logs "Downloading full binary" and calls downloadFullBinary().downloadBinaryToTemp() calls waitForBinaryVisible(tempPath) before spawning the downloaded binary, then clears the consumed patch cache via best-effort clearPatchCache().catch(...), sets mode 0o755 unless process.platform === "win32", and returns { tempBinaryPath: tempPath, lockPath, patchBytes }.acquireLock recognizes process.ppid and takes over, making the parent’s later release a harmless no-op. Any error inside downloadBinaryToTemp() releases lockPath before rethrowing.tryDeltaUpgrade() delegates to attemptDeltaUpgrade(version, process.execPath, destPath, offline, setMessage), using the currently running executable as the patch base.downloadFullBinary() routes nightly versions to downloadNightlyToPath(destPath, version, setMessage) and stable versions to downloadStableToPath(downloadTag ?? version, destPath, setMessage).brew upgrade getsentry/tools/sentry; the requested version is intentionally ignored because Homebrew’s tap formula controls the version and does not support arbitrary release pinning. A nonzero exit throws UpgradeError("execution_failed", \brew upgrade failed with exit code ${code}`), while spawn errors throw UpgradeError("execution_failed", `brew failed: ${err.message}`)`.["global", "add", \sentry@${version}`]; npm, pnpm, and Bun use ["install", "-g", `sentry@${version}`]. Spawn uses inherited stdio and shell: process.platform === "win32"because npm/pnpm/yarn executables are.cmd` files on Windows.executeUpgrade() dispatches "curl" to downloadBinaryToTemp(), "brew" to executeUpgradeHomebrew(), and "npm", "pnpm", "bun", or "yarn" to executeUpgradePackageManager(); package-manager methods return null, while unknown methods throw UpgradeError("unknown_method").