[PR #30556] refactor(nodejs-client): remove axios dependency and use native fetch API #32876

Closed
opened 2026-02-21 20:52:14 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/30556

State: closed
Merged: No


Summary

This PR removes the axios dependency from the nodejs-client SDK and replaces it with Node.js native fetch API, reducing external dependencies and improving maintainability.

Changes

Core Refactoring

  • Replace axios with native fetch API for all HTTP requests
  • Implement proper timeout control using AbortController
  • Convert web ReadableStream to Node.js Readable for streaming responses
  • Maintain all existing error types and retry logic

Code Quality

  • Fix critical timeout handling bug in retry loop
  • Add proper type assertions with explanatory comments
  • Pass all TypeScript type checks
  • Pass all ESLint checks

Dependencies

  • Remove axios from package.json
  • Update pnpm-lock.yaml (removes 81 packages)
  • Zero production dependencies

Testing

  • Update all test mocks to use fetch
  • All 85 tests passing
  • No breaking changes to public API

Versioning

  • Bump version from 3.0.0 to 3.1.0

Commits

  1. refactor(nodejs-client): replace axios with native fetch API - Core implementation
  2. chore(nodejs-client): bump version to 3.1.0 - Version update
  3. chore(nodejs-client): update pnpm-lock.yaml to remove axios - Lockfile cleanup
  4. fix(nodejs-client): fix all test mocks for fetch API - Test updates
  5. fix(nodejs-client): fix timeout handling in retry loop - Critical bug fix

Benefits

  • Reduced dependencies: Removes axios and ~81 related packages
  • Smaller bundle size: ~800KB reduction
  • Native API: Uses built-in Node.js 18+ fetch
  • Better performance: Native fetch is faster than axios
  • Easier maintenance: Fewer dependencies to update

Testing

pnpm type-check  # ✅ Pass
pnpm lint        # ✅ Pass  
pnpm test        # ✅ 85/85 tests passing
pnpm build       # ✅ Build successful (54KB)

Breaking Changes

None. This is a fully backward-compatible refactoring.

Related Issue

Closes #30555

Checklist

  • Code follows project conventions
  • All tests passing
  • TypeScript types are correct
  • ESLint checks passing
  • Build successful
  • No breaking changes
  • Documentation updated (if needed)
**Original Pull Request:** https://github.com/langgenius/dify/pull/30556 **State:** closed **Merged:** No --- ## Summary This PR removes the axios dependency from the nodejs-client SDK and replaces it with Node.js native fetch API, reducing external dependencies and improving maintainability. ## Changes ### Core Refactoring - ✅ Replace axios with native fetch API for all HTTP requests - ✅ Implement proper timeout control using AbortController - ✅ Convert web ReadableStream to Node.js Readable for streaming responses - ✅ Maintain all existing error types and retry logic ### Code Quality - ✅ Fix critical timeout handling bug in retry loop - ✅ Add proper type assertions with explanatory comments - ✅ Pass all TypeScript type checks - ✅ Pass all ESLint checks ### Dependencies - ✅ Remove axios from package.json - ✅ Update pnpm-lock.yaml (removes 81 packages) - ✅ Zero production dependencies ### Testing - ✅ Update all test mocks to use fetch - ✅ All 85 tests passing - ✅ No breaking changes to public API ### Versioning - ✅ Bump version from 3.0.0 to 3.1.0 ## Commits 1. `refactor(nodejs-client): replace axios with native fetch API` - Core implementation 2. `chore(nodejs-client): bump version to 3.1.0` - Version update 3. `chore(nodejs-client): update pnpm-lock.yaml to remove axios` - Lockfile cleanup 4. `fix(nodejs-client): fix all test mocks for fetch API` - Test updates 5. `fix(nodejs-client): fix timeout handling in retry loop` - Critical bug fix ## Benefits - **Reduced dependencies**: Removes axios and ~81 related packages - **Smaller bundle size**: ~800KB reduction - **Native API**: Uses built-in Node.js 18+ fetch - **Better performance**: Native fetch is faster than axios - **Easier maintenance**: Fewer dependencies to update ## Testing ```bash pnpm type-check # ✅ Pass pnpm lint # ✅ Pass pnpm test # ✅ 85/85 tests passing pnpm build # ✅ Build successful (54KB) ``` ## Breaking Changes None. This is a fully backward-compatible refactoring. ## Related Issue Closes #30555 ## Checklist - [x] Code follows project conventions - [x] All tests passing - [x] TypeScript types are correct - [x] ESLint checks passing - [x] Build successful - [x] No breaking changes - [x] Documentation updated (if needed)
yindo added the pull-request label 2026-02-21 20:52:14 -05:00
yindo closed this issue 2026-02-21 20:52:14 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#32876