Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 142a60d

Browse files
committed
fix(nitro-node): use cross-fetch on environments which do not have fetch
1 parent d10bbbb commit 142a60d

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

nitro-node/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"typescript": "^5.3.3"
6060
},
6161
"dependencies": {
62+
"cross-fetch": "^4.0.0",
6263
"download": "^8.0.0",
6364
"fetch-retry": "^5.0.6",
6465
"os-utils": "^0.0.14",

nitro-node/src/nitro.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ import { checkMagicBytes, getResourcesInfo } from "./utils";
1616
import { log } from "./logger";
1717
import { updateNvidiaInfo } from "./nvidia";
1818
import { promptTemplateConverter } from "./prompt";
19+
import crossFetch from "cross-fetch";
1920
// Polyfill fetch with retry
20-
const fetchRetry = fetchRT(fetch);
21+
const fetchRetry = fetchRT(globalThis.fetch ?? crossFetch);
2122

2223
// The PORT to use for the Nitro subprocess
2324
const PORT = 3928;

nitro-node/src/scripts/download-nitro.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import fs from "node:fs";
22
import path from "node:path";
33
import download from "download";
44
import { Duplex } from "node:stream";
5+
import crossFetch from "cross-fetch";
56

67
// Define nitro version to download in env variable ("latest" or tag "v1.2.3")
78
const NITRO_VERSION = process.env.NITRO_VERSION || "latest";
@@ -20,7 +21,7 @@ const getReleaseInfo = async (taggedVersion: string): Promise<any> => {
2021
if (!releaseUrlPrefix) throw Error(`Invalid version: ${taggedVersion}`);
2122
const url = `${releaseUrlPrefix}${taggedVersion}`;
2223
console.log(`[Getting release info] ${url}`);
23-
const response = await fetch(url, {
24+
const response = await crossFetch(url, {
2425
headers: {
2526
Accept: "application/vnd.github+json",
2627
"X-GitHub-Api-Version": "2022-11-28",

0 commit comments

Comments
 (0)