If two requests are made to the same data, if the second request is made while the first request is still "in flight" it will return both "error" and "data" as undefined instead of the promise to the inflight request.
This is because during a second call to the same data, while the first call is 'in flight':
🐞 Bug Report
Describe the bug
If two requests are made to the same data, if the second request is made while the first request is still "in flight" it will return both "error" and "data" as undefined instead of the promise to the inflight request.
This is because during a second call to the same data, while the first call is 'in flight':
This block will be skipped, because we do have a cacheSelector via
oneFetchye
: https://github.com/americanexpress/fetchye/blob/main/packages/fetchye/src/makeServerFetchye.js#L42This block will be skipped, because the request is
loading
: https://github.com/americanexpress/fetchye/blob/main/packages/fetchye/src/makeServerFetchye.js#L54The function will then "syncronously" return the
data
,error
, andrun
fields: https://github.com/americanexpress/fetchye/blob/main/packages/fetchye/src/makeServerFetchye.js#L64However
data
anderror
will be undefined because the original request is still in flight.To Reproduce
Define two sequenced functions (in psuedo code):
Then race them:
Note: This bug is also present if you are calling for the same data from multiple one-app modules.
Whichever call to
logIn
happens second will "synchronously" receiveundefined
as thetoken
.Expected behavior
Both calls to get the token properly return a promise to the data from the single call made