From 05d15386a7f33d04c89323f53654dc1e447c36af Mon Sep 17 00:00:00 2001 From: easonysliu Date: Tue, 17 Mar 2026 17:11:47 +0800 Subject: [PATCH] fix: make AxiosError.cause non-enumerable to prevent circular reference in JSON.stringify --- lib/core/AxiosError.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/AxiosError.js b/lib/core/AxiosError.js index f28b8861..138d3194 100644 --- a/lib/core/AxiosError.js +++ b/lib/core/AxiosError.js @@ -5,7 +5,7 @@ import utils from '../utils.js'; class AxiosError extends Error { static from(error, code, config, request, response, customProps) { const axiosError = new AxiosError(error.message, code || error.code, config, request, response); - axiosError.cause = error; + Object.defineProperty(axiosError, 'cause', {value: error, configurable: true, writable: true}); axiosError.name = error.name; // Preserve status from the original error if not already set from response