File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -282,9 +282,27 @@ const AsyncStorage = {
282
282
return value ;
283
283
} ) ;
284
284
const reqLength = getRequests . length ;
285
+
286
+ /**
287
+ * As mentioned few lines above, this method could be called with the array of potential error,
288
+ * in case of anything goes wrong. The problem is, if any of the batched calls fails
289
+ * the rest of them would fail too, but the error would be consumed by just one. The rest
290
+ * would simply return `undefined` as their result, rendering false negatives.
291
+ *
292
+ * In order to avoid this situation, in case of any call failing,
293
+ * the rest of them will be rejected as well (with the same error).
294
+ */
295
+ const errorList = convertErrors ( errors ) ;
296
+ const error = errorList && errorList . length ? errorList [ 0 ] : null ;
297
+
285
298
for ( let i = 0 ; i < reqLength ; i ++ ) {
286
299
const request = getRequests [ i ] ;
287
300
const requestKeys = request . keys ;
301
+ if ( error ) {
302
+ request . callback && request . callback ( error ) ;
303
+ request . reject && request . reject ( error ) ;
304
+ continue ;
305
+ }
288
306
const requestResult = requestKeys . map ( ( key ) => [ key , map [ key ] ] ) ;
289
307
request . callback && request . callback ( null , requestResult ) ;
290
308
request . resolve && request . resolve ( requestResult ) ;
You can’t perform that action at this time.
0 commit comments