fix(coding-agent): fix startup crash when downloading fd/ripgrep on first run
Use pipeline() instead of finished(readable.pipe(writable)) so stream errors from abort signals are caught as promise rejections. Increase download timeout from 10s to 120s for multi-MB archives. closes #2066
This commit is contained in:
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed startup crash when downloading `fd`/`ripgrep` on first run by using `pipeline()` instead of `finished(readable.pipe(writable))` so stream errors from timeouts are caught properly, and increased the download timeout from 10s to 120s ([#2066](https://github.com/badlogic/pi-mono/issues/2066))
|
||||||
|
|
||||||
## [0.58.0] - 2026-03-14
|
## [0.58.0] - 2026-03-14
|
||||||
|
|
||||||
### New Features
|
### New Features
|
||||||
|
|||||||
@@ -5,11 +5,12 @@ import { chmodSync, createWriteStream, existsSync, mkdirSync, readdirSync, renam
|
|||||||
import { arch, platform } from "os";
|
import { arch, platform } from "os";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import { Readable } from "stream";
|
import { Readable } from "stream";
|
||||||
import { finished } from "stream/promises";
|
import { pipeline } from "stream/promises";
|
||||||
import { APP_NAME, getBinDir } from "../config.js";
|
import { APP_NAME, getBinDir } from "../config.js";
|
||||||
|
|
||||||
const TOOLS_DIR = getBinDir();
|
const TOOLS_DIR = getBinDir();
|
||||||
const NETWORK_TIMEOUT_MS = 10000;
|
const NETWORK_TIMEOUT_MS = 10_000;
|
||||||
|
const DOWNLOAD_TIMEOUT_MS = 120_000;
|
||||||
|
|
||||||
function isOfflineModeEnabled(): boolean {
|
function isOfflineModeEnabled(): boolean {
|
||||||
const value = process.env.PI_OFFLINE;
|
const value = process.env.PI_OFFLINE;
|
||||||
@@ -116,7 +117,7 @@ async function getLatestVersion(repo: string): Promise<string> {
|
|||||||
// Download a file from URL
|
// Download a file from URL
|
||||||
async function downloadFile(url: string, dest: string): Promise<void> {
|
async function downloadFile(url: string, dest: string): Promise<void> {
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
signal: AbortSignal.timeout(NETWORK_TIMEOUT_MS),
|
signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
@@ -128,7 +129,7 @@ async function downloadFile(url: string, dest: string): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const fileStream = createWriteStream(dest);
|
const fileStream = createWriteStream(dest);
|
||||||
await finished(Readable.fromWeb(response.body as any).pipe(fileStream));
|
await pipeline(Readable.fromWeb(response.body as any), fileStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
function findBinaryRecursively(rootDir: string, binaryFileName: string): string | null {
|
function findBinaryRecursively(rootDir: string, binaryFileName: string): string | null {
|
||||||
|
|||||||
Reference in New Issue
Block a user