Race a real promise against a timeout rejection.
Wrap any promise in a timeout. Build a helper:
```
function withTimeout(promise, ms) {
return Promise.race([
promise,
new Promise((_, reject) => setTimeout(() => reject(new Error("timeout")), ms))
]);
}
```
Then call withTimeout with a slow promise and a 100ms timeout.Sign in to save your code and track progress across devices.