@@ -5,6 +5,7 @@ import type {
5
5
LoaderStats ,
6
6
Loader ,
7
7
LoaderConfiguration ,
8
+ LoaderResponse ,
8
9
} from '../types/loader' ;
9
10
import { LoadStats } from '../loader/load-stats' ;
10
11
import { RetryConfig } from '../config' ;
@@ -197,17 +198,18 @@ class XhrLoader implements Loader<LoaderContext> {
197
198
if ( ! this . callbacks ) {
198
199
return ;
199
200
}
200
- const response = {
201
+ const response : LoaderResponse = {
201
202
url : xhr . responseURL ,
202
203
data : data ,
204
+ code : status ,
203
205
} ;
204
206
205
207
this . callbacks . onSuccess ( response , stats , context , xhr ) ;
206
208
} else {
207
209
const retryConfig = config . loadPolicy . errorRetry ;
208
210
const retryCount = stats . retry ;
209
211
// if max nb of retries reached or if http status between 400 and 499 (such error cannot be recovered, retrying is useless), return error
210
- if ( shouldRetry ( retryConfig , retryCount , status ) ) {
212
+ if ( shouldRetry ( retryConfig , retryCount , false , status ) ) {
211
213
this . retry ( retryConfig ) ;
212
214
} else {
213
215
logger . error ( `${ status } while loading ${ context . url } ` ) ;
@@ -226,7 +228,7 @@ class XhrLoader implements Loader<LoaderContext> {
226
228
loadtimeout ( ) : void {
227
229
const retryConfig = this . config ?. loadPolicy . timeoutRetry ;
228
230
const retryCount = this . stats . retry ;
229
- if ( shouldRetry ( retryConfig , retryCount ) ) {
231
+ if ( shouldRetry ( retryConfig , retryCount , true ) ) {
230
232
this . retry ( retryConfig ) ;
231
233
} else {
232
234
logger . warn ( `timeout while loading ${ this . context . url } ` ) ;
0 commit comments