/
githubmirror
/
axios
Обзор
Документация
Войти
/
githubmirror
/
axios
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v1.x
tests/unit/core/Axios.test.js
56 строк
2 KB
Yen Su
fix(core): tolerate non-string stack when decorating request errors (#11109)
29 июл 2026, 20:58
Не верифицирован
29 июл 2026, 20:58
a75bf44
Код
Авторство
О чём код?
import { describe, it, expect } from 'vitest'; import axios from '../../../index.js'; describe('core::Axios', () => { describe('request error stack decoration', () => { async function expectAdapterFailurePreserved() { const failure = new Error('adapter failure'); await expect( axios.request({ url: 'http://localhost/test', adapter: () => Promise.reject(failure), }) ).rejects.toBe(failure); } it('preserves the original error when Error.prepareStackTrace returns a non-string stack', async () => { const original = Error.prepareStackTrace; // Simulates instrumentation that overrides the V8 hook to return // structured call-site data instead of a formatted string. Error.prepareStackTrace = () => ({}); try { await expectAdapterFailurePreserved(); } finally { Error.prepareStackTrace = original; } }); it('preserves the original error when Error.prepareStackTrace throws', async () => { const original = Error.prepareStackTrace; Error.prepareStackTrace = () => { throw new Error('stack formatting failure'); }; try { await expectAdapterFailurePreserved(); } finally { Error.prepareStackTrace = original; } }); it('preserves the original error when Error.captureStackTrace throws', async () => { const original = Error.captureStackTrace; Error.captureStackTrace = () => { throw new Error('stack capture failure'); }; try { await expectAdapterFailurePreserved(); } finally { Error.captureStackTrace = original; } }); }); });