Skip to content

Commit c2a7d06

Browse files
rickstaaclaudeweb-flow
authored
fix: replace direct axios usage with native fetch (#615)
* fix: add prettier as explicit devDependency prettier was used in format scripts and pre-commit hooks but was never declared as a dependency — it only worked as a ghost dependency via transitive hoisting. This breaks on pnpm 10+ which is stricter about hoisting. Also ignore .pnpm-store in .gitignore and .prettierignore. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: add dev container and .npmrc for supply chain security Isolate development in a container to limit blast radius of compromised packages, and enforce frozen-lockfile + ignore-scripts via .npmrc. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: upgrade to pnpm 10 for built-in supply chain security pnpm 10+ blocks dependency install scripts (postinstall, preinstall) by default, replacing the need for ignore-scripts in .npmrc. This protects against malicious packages without breaking the project's own lifecycle hooks (e.g. prepare: husky). See: https://pnpm.io/supply-chain-security Changes: - Remove .npmrc (ignore-scripts no longer needed, frozen-lockfile is enforced by CI via --frozen-lockfile flag) - Bump packageManager to pnpm@10.33.0 - Update CI workflows to use pnpm 10.33.0 - Update README to document pnpm 10 approach and link to docs - Update devcontainer image tag Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: simplify dev container and supply chain sections in README Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: replace axios with native fetch to reduce supply chain attack surface Remove axios and wait-on dependencies, replacing the axios-based fetcher with a native fetch implementation that preserves the same error handling and timeout behavior. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: keep fetch timeout active until body is fully consumed Address Copilot review: move clearTimeout after body read so the AbortController covers slow-streaming responses, and enrich non-2xx errors with statusText. Co-Authored-By: copilot-pull-request-reviewer[bot] <noreply@github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: copilot-pull-request-reviewer[bot] <noreply@github.com>
1 parent 5f49e35 commit c2a7d06

5 files changed

Lines changed: 30 additions & 110 deletions

File tree

lib/axios.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

lib/fetcher.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
export const fetcher = <T>(url: string): Promise<T> => {
2+
const controller = new AbortController();
3+
const timeoutId = setTimeout(() => controller.abort(), 10000);
4+
5+
return fetch(`/api${url}`, { signal: controller.signal })
6+
.then(async (res) => {
7+
if (!res.ok) {
8+
const apiError = await res.json().catch(() => null);
9+
clearTimeout(timeoutId);
10+
if (apiError?.code) {
11+
const errorMessage = apiError.error ?? "An unknown error occurred";
12+
throw new Error(`${apiError.code}: ${errorMessage}`);
13+
}
14+
const statusText = res.statusText ? ` ${res.statusText}` : "";
15+
throw new Error(`HTTP ${res.status}${statusText}`);
16+
}
17+
const data = (await res.json()) as T;
18+
clearTimeout(timeoutId);
19+
return data;
20+
})
21+
.catch((err) => {
22+
clearTimeout(timeoutId);
23+
if (err.name === "AbortError") {
24+
throw new Error("Request timeout");
25+
}
26+
throw err;
27+
});
28+
};

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@
4646
"jest-environment-jsdom": "^30.2.0",
4747
"ts-node": "^10.9.2",
4848
"typechain": "^8.1.0",
49-
"typescript": "5.9.2",
50-
"wait-on": "^9.0.3"
49+
"typescript": "5.9.2"
5150
},
5251
"dependencies": {
5352
"@apollo/client": "3.13.1",
@@ -75,7 +74,6 @@
7574
"apollo-link": "^1.2.11",
7675
"apollo-link-http": "^1.5.15",
7776
"apollo-server-micro": "3.10.0",
78-
"axios": "^0.30.3",
7977
"change-case": "^4.1.2",
8078
"copy-to-clipboard": "^3.3.3",
8179
"dayjs": "^1.9.6",

pages/_app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import "@rainbow-me/rainbowkit/styles.css";
22
import "../styles/globals.css";
33

44
import { ApolloProvider } from "@apollo/client";
5-
import { fetcher } from "@lib/axios";
5+
import { fetcher } from "@lib/fetcher";
66
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
77
import { DEFAULT_CHAIN, L1_CHAIN } from "lib/chains";
88
import dynamic from "next/dynamic";

pnpm-lock.yaml

Lines changed: 0 additions & 87 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)