amis-rpc-design/node_modules/@pmmmwh/react-refresh-webpack-plugin/client/utils/retry.js

24 lines
526 B
JavaScript
Raw Normal View History

2023-10-07 19:42:30 +08:00
function runWithRetry(callback, maxRetries) {
function executeWithRetryAndTimeout(currentCount) {
try {
if (currentCount > maxRetries - 1) {
console.warn('[React Refresh] Failed to set up the socket connection.');
return;
}
callback();
} catch (err) {
setTimeout(
function () {
executeWithRetryAndTimeout(currentCount + 1);
},
Math.pow(10, currentCount)
);
}
}
executeWithRetryAndTimeout(0);
}
module.exports = runWithRetry;