Skip to content

feat: remove the axios runtime dependency#366

Merged
hoegertn merged 3 commits into
mainfrom
claude/access-dependency-spec-EPERw
May 15, 2026
Merged

feat: remove the axios runtime dependency#366
hoegertn merged 3 commits into
mainfrom
claude/access-dependency-spec-EPERw

Conversation

@hoegertn
Copy link
Copy Markdown
Contributor

Summary

Spec document analyzing whether the axios runtime dependency can be removed from cdk-serverless.

TL;DR: Yes — axios is used in exactly two files (src/lambda/auth.ts and src/tests/integ-test-util.ts) and can be replaced with the platform-native fetch API. Lambda already runs on NODEJS_LATEST (Node 22), so the runtime requirement is met without any minimum-version bump.

The spec lays out:

  • Where axios is used today, with line refs.
  • A two-phase replacement plan:
    • Phase 1 (auth.ts) — pure internal refactor, non-breaking, removes axios from every Lambda bundle that pulls in cdk-serverless/lambda.
    • Phase 2 (IntegTestUtil) — touches the public API (getClient / getAuthenticatedClient return an Axios instance today). Two options presented:
      • Option A — replace with a thin fetch-based HttpClient. Cleaner end state, breaking change for test consumers.
      • Option B — leave axios in IntegTestUtil but move it to peerDependencies so it stops being pulled into Lambda consumers transitively.
  • API-impact table for breaking-change tracking.
  • Migration notes for consumers (.data.json(), etc.).
  • Testing strategy (unit tests against mocked JWKS/well-known endpoints, integ test re-run, bundle-size delta).
  • Alternatives considered (node-fetch, undici directly, vendored wrapper).
  • Open questions including timeout handling (AbortSignal.timeout).

Recommendation in the spec is Option A in a feat!: major bump, with Phase 1 landed first as a non-breaking step.

Review request

Please review the spec at specs/remove-axios-dependency.md. Particularly interested in:

  1. Option A vs. Option B for IntegTestUtil — willing to take the breaking change, or keep axios as a peer dep there?
  2. Should the spec also cover adding an AbortSignal.timeout(5000) on the JWKS/well-known fetches as part of Phase 1, or keep behavior-parity and file separately?
  3. Anything missing — e.g. concerns about fetch in the AWS Lambda Node runtime that I haven't accounted for?

Once approved, I'll implement the chosen approach in a follow-up PR.

https://claude.ai/code/session_01LbWtFPLw9GBJxkZfPis5Lo


Generated by Claude Code

claude and others added 3 commits May 15, 2026 07:12
Analyzes the two call sites that import axios today
(src/lambda/auth.ts and src/tests/integ-test-util.ts), proposes a
two-phase replacement with native fetch, and lays out the API and
breaking-change implications for IntegTestUtil consumers.

https://claude.ai/code/session_01LbWtFPLw9GBJxkZfPis5Lo
Replace axios with the platform-native fetch API across the library:

- src/lambda/auth.ts: JWKS and well-known issuer lookups now use fetch
  with a 5s AbortSignal timeout. Errors surface as Error instead of
  AxiosError; visible authorizer behavior is unchanged.
- src/tests/integ-test-util.ts: getClient() and getAuthenticatedClient()
  now return a small HttpClient backed by fetch (BREAKING). The new
  client exposes get/post/put/patch/delete; response shape changes from
  axios's { data, status } to { body, status, ok, headers, json() }.
- src/tests/http-client.ts: new minimal HttpClient with baseURL and
  default-header support.
- package.json / .projenrc.ts: drop axios from runtime dependencies.

Motivation is supply-chain security: axios has had repeated security
advisories and removing it permanently is cheaper than chasing CVE
upgrades. Lambda already runs Node 22 (Runtime.NODEJS_LATEST), so
fetch is available natively.

Migration notes for IntegTestUtil consumers are documented in README.

https://claude.ai/code/session_01LbWtFPLw9GBJxkZfPis5Lo
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@hoegertn hoegertn changed the title docs: spec for removing the axios runtime dependency feat: remove the axios runtime dependency May 15, 2026
@hoegertn hoegertn merged commit facd389 into main May 15, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants