Bug Description
`DOMUtils.waitForAnimation()` (lines 133-141 in `src/utils/DOMUtils.js`) returns a Promise that resolves when an animation/transition ends, but has no timeout:
```js
static waitForAnimation(element, eventType = 'animationend') {
return new Promise(resolve => {
const handler = () => {
element.removeEventListener(eventType, handler);
resolve();
};
element.addEventListener(eventType, handler);
});
}
```
If the animation is cancelled, the element is removed from DOM, or no animation actually fires, the Promise never resolves. Any `await` on this call will hang indefinitely.
Impact
- Calling code that `await`s this method can freeze if the animation doesn't fire
- No way for callers to recover from a hung animation wait
- Memory leak: the event listener is never removed if the event never fires
Expected Fix
Add a timeout with a fallback:
```js
static waitForAnimation(element, eventType = 'animationend', timeout = 5000) {
return new Promise(resolve => {
const handler = () => {
element.removeEventListener(eventType, handler);
clearTimeout(timer);
resolve();
};
element.addEventListener(eventType, handler);
const timer = setTimeout(handler, timeout);
});
}
```
Files
- `src/utils/DOMUtils.js:133-141`
Bug Description
`DOMUtils.waitForAnimation()` (lines 133-141 in `src/utils/DOMUtils.js`) returns a Promise that resolves when an animation/transition ends, but has no timeout:
```js
static waitForAnimation(element, eventType = 'animationend') {
return new Promise(resolve => {
const handler = () => {
element.removeEventListener(eventType, handler);
resolve();
};
element.addEventListener(eventType, handler);
});
}
```
If the animation is cancelled, the element is removed from DOM, or no animation actually fires, the Promise never resolves. Any `await` on this call will hang indefinitely.
Impact
Expected Fix
Add a timeout with a fallback:
```js
static waitForAnimation(element, eventType = 'animationend', timeout = 5000) {
return new Promise(resolve => {
const handler = () => {
element.removeEventListener(eventType, handler);
clearTimeout(timer);
resolve();
};
element.addEventListener(eventType, handler);
const timer = setTimeout(handler, timeout);
});
}
```
Files