Skip to content

Commit

Permalink
optimize "Network request failed" retry case #147
Browse files Browse the repository at this point in the history
  • Loading branch information
adrai committed Aug 21, 2024
1 parent 541b257 commit f735b91
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 2.6.1

- optimize "Failed to fetch" retry case [147](https://github.com/i18next/i18next-http-backend/issues/147)

### 2.6.0

- fix "Failed to fetch" retry case [147](https://github.com/i18next/i18next-http-backend/issues/147)
Expand Down
2 changes: 1 addition & 1 deletion i18nextHttpBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ var Backend = function () {
this.options.request(this.options, url, payload, function (err, res) {
if (res && (res.status >= 500 && res.status < 600 || !res.status)) return callback('failed loading ' + url + '; status code: ' + res.status, true);
if (res && res.status >= 400 && res.status < 500) return callback('failed loading ' + url + '; status code: ' + res.status, false);
if (!res && err && err.message && (err.message.indexOf('Failed to fetch') > -1 || err.message.indexOf('failed') > -1 && err.message.indexOf('fetch') > -1)) return callback('failed loading ' + url + ': ' + err.message, true);
if (!res && err && err.message && err.message.toLowerCase().indexOf('failed') > -1 && (err.message.indexOf('fetch') > -1 || err.message.toLowerCase().indexOf('network') > -1)) return callback('failed loading ' + url + ': ' + err.message, true);
if (err) return callback(err, false);
var ret, parseErr;
try {
Expand Down
Loading

0 comments on commit f735b91

Please sign in to comment.