Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
### Fixed
- Error for empty `restClientConfig` while using HTTP retries.

## [5.5.7] - 2025-12-09
### Changed
Expand Down
20 changes: 20 additions & 0 deletions __tests__/rest.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,26 @@ describe('RestClient', () => {
};
expect(retryConfig.retryCondition(timeoutError)).toBe(true);
});

it('handles undefined restClientConfig without crashing during retries', () => {
const client = new RestClient({
baseURL: options.baseURL,
headers: options.headers,
restClientConfig: undefined,
});

const retryConfig = client.getRetryConfig();
expect(retryConfig.retries).toBe(6);

const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
const onRetry = retryConfig.onRetry;

expect(() => {
onRetry(1, { code: 'ECONNABORTED' }, { method: 'GET', url: 'http://test.com' });
}).not.toThrow();

consoleSpy.mockRestore();
});
});

describe('buildPath', () => {
Expand Down
2 changes: 1 addition & 1 deletion lib/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ method: ${method}`,
getRetryConfig() {
const retryOption = this.restClientConfig?.retry;
const onRetry = (retryCount, error, requestConfig) => {
if (this.restClientConfig.debug) {
if (this.restClientConfig?.debug) {
console.log(`[retry #${retryCount}] ${requestConfig.method?.toUpperCase()} ${requestConfig.url} -> ${error.code || error.message}`);
}
};
Expand Down
Loading