Commit f164d4e
committed
Fix upgrade silently replacing wrong binary (execPath bug) and swallowing errors
Root cause: in some compiled Bun versions, process.execPath returns the Bun
runtime path (~/.bun/bin/bun) or an internal /$bunfs/ path instead of the
deployed binary path. This causes the mv to either fail (text file busy) or
replace the wrong file, with the error going silently to stderr.
Fixes:
- github-code-search.ts: derive selfPath with a guard — if process.execPath
starts with '/$bunfs/' (internal Bun path) fall back to resolve(argv[0]).
Wrap performUpgrade in a try/catch that prints errors to STDOUT so they are
always visible.
- upgrade.ts (downloadBinary): read response body explicitly with
arrayBuffer() instead of passing the Response object to Bun.write (avoids
edge-case body streaming issues). Validate the downloaded size is non-zero.
Print a 'Replacing <dest>...' diagnostic so the target path is visible.
- upgrade.test.ts: add tests for downloadBinary paths (non-ok download,
empty body, full success) to keep coverage above the 75% threshold.
Refs #451 parent ca14c90 commit f164d4e
1 file changed
Lines changed: 73 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
0 commit comments