Too long requests might be called twice?
as reported by @nicofrand on IRC. Could be reproduced with the following code in the fake source:
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
// Fetch accounts, including new accounts, and operations using the backend and
// return both to the client.
export async function fetchAccounts(req, res) {
log.info("FETCH ACCOUNTS ----------------");
try {
let access = req.preloaded.access;
if (!access.enabled) {
let errcode = getErrorCode('DISABLED_ACCESS');
throw new KError('disabled access', 403, errcode);
}
console.log('Taking a break...');
await sleep(3 * 60 * 1000);
await accountManager.retrieveAndAddAccountsByAccess(access);
let { accounts, newOperations } = await accountManager.retrieveOperationsByAccess(access);
res.status(200).json({
accounts,
newOperations
});
} catch (err) {
return asyncErr(res, err, 'when fetching accounts');
}
}
It needs proper investigation to understand what's going on. Is it the browser repeating the request secretly? Or the router trying to call the controller function again? Or something else we're doing badly?