Commit eb898ac
authored
fix(upgrade): remove v prefix from release URLs and work around Bun.write streaming bug (#243)
## Summary
Fixes two bugs that prevent `sentry cli upgrade` from working for
curl-installed users (CLI-5F):
1. **`v` prefix on release URLs** — `getBinaryDownloadUrl()` and
`versionExists()` constructed GitHub release URLs with a `v` prefix
(e.g., `/download/v0.10.1/...`), but this repo's tags are un-prefixed
(`0.10.1`), causing HTTP 404 errors.
2. **`Bun.write(path, Response)` event-loop bug** — Even with correct
URLs, `Bun.write(tempPath, response)` with a large streaming HTTP
response body doesn't properly keep the Bun event loop alive. The
process exits mid-download with code 0 and no error output. The
workaround is to materialise the body first via `await
response.arrayBuffer()`, then write the buffer.
## Changes
**`src/lib/binary.ts`**
- Remove `v` prefix from download URL template in
`getBinaryDownloadUrl()`
**`src/lib/upgrade.ts`**
- Remove `v` prefix from version-exists tag check URL in
`versionExists()`
- Replace `Bun.write(tempPath, response)` with `response.arrayBuffer()`
+ `Bun.write(tempPath, body)` to work around the Bun streaming bug
**Tests** — Updated URL assertions and mocks across 3 test files to
match the un-prefixed tag format.
## How the Bun bug was diagnosed
`strace` showed the process actively receiving data from GitHub's CDN,
then calling `exit_group(0)` mid-download. Adding debug logging
confirmed `Bun.write(path, Response)` starts but its `await` never
resolves — the event loop drains and the process exits cleanly. A
standalone repro (`await Bun.write(path, await fetch(url))`) hangs
indefinitely, but within the CLI's async call stack, the process exits.
Materialising the body first with `arrayBuffer()` fixes both cases.1 parent e0233bd commit eb898ac
File tree
5 files changed
+18
-14
lines changed- src/lib
- test
- commands/cli
- lib
5 files changed
+18
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
319 | | - | |
| 319 | + | |
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
| |||
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
391 | | - | |
392 | | - | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
393 | 397 | | |
394 | 398 | | |
395 | 399 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
111 | | - | |
112 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
437 | 437 | | |
438 | 438 | | |
439 | 439 | | |
440 | | - | |
441 | | - | |
| 440 | + | |
| 441 | + | |
442 | 442 | | |
443 | | - | |
| 443 | + | |
444 | 444 | | |
445 | 445 | | |
446 | 446 | | |
| |||
0 commit comments