From 96956e30ba2768b754d53125af832c9ccf66a9cd Mon Sep 17 00:00:00 2001 From: Dobes Vandermeer Date: Thu, 16 Sep 2021 12:16:43 -0700 Subject: [PATCH] Improve timeout error when timeout is browser default (#3209) I seems like the browser imposes a default timeout despite the documented default timeout being "never". When this timeout occurs, axios confusingly reports an error "timeout of 0ms exceeded". This change the message to avoid the confusing "0ms" part. Co-authored-by: Jay --- lib/adapters/xhr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/adapters/xhr.js b/lib/adapters/xhr.js index a386dd2..48d2e8e 100644 --- a/lib/adapters/xhr.js +++ b/lib/adapters/xhr.js @@ -104,7 +104,7 @@ module.exports = function xhrAdapter(config) { // Handle timeout request.ontimeout = function handleTimeout() { - var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded'; + var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded'; if (config.timeoutErrorMessage) { timeoutErrorMessage = config.timeoutErrorMessage; }