ResizeObserver loop completed with undelivered notifications: how to fix it
IntermediateBrowser and web interview questionBy UIRound, updated 3 December 2026
Short answer
ResizeObserver loop completed with undelivered notifications means a ResizeObserver callback changed the size of observed elements in the same frame, so the browser could not deliver every resize notification before painting. It moves the rest to the next frame and fires an error event on window. Often it is harmless, but it can mean a real layout loop. Fix it by deferring the change with requestAnimationFrame or by skipping updates when the size has not changed.
What the browser is doing
The specification runs resize observers once per frame, after layout and before paint. If a callback changes styles, the browser has to lay out again, which can produce new size changes and more notifications.
To stop an endless cycle inside one frame, the spec only keeps going for elements that are deeper in the DOM than the ones already handled. Notifications for elements at the same depth or shallower are left for the next frame. When that happens, the browser reports an ErrorEvent whose message is exactly "ResizeObserver loop completed with undelivered notifications."
So the message is not a crash in your code. It is the browser telling you that it cut a cycle short.
Why it shows up as an error
The browser reports it through the same path as an uncaught exception, so anything listening for window errors sees it:
- Development overlays, such as webpack-dev-server's runtime error overlay, which covers the page.
- Error trackers, which log it like any other uncaught error.
- End-to-end test runners that fail a test on any uncaught page error.
The spec only sets a message on the event. There is no stack trace from your code, which is why it is hard to trace back to a component. A try/catch around your callback will not catch it, because your callback did not throw.
Is it harmful?
MDN draws the line clearly:
- It appears once or a few times, then stops. The observer settles and the layout ends up correct. Users may see a brief flash of wrong layout, because work meant for one frame was spread over several.
- It repeats every frame. You have a real feedback loop: each callback changes a size, which triggers the callback again. The check only stops the browser from freezing. It does not stop the loop.
Find out which one you have before deciding to ignore it.
Fix 1: defer the change to the next frame
If the callback must change the layout, do it in a requestAnimationFrame callback, so it runs after the browser paints:
const observer = new ResizeObserver((entries) => {
requestAnimationFrame(() => {
for (const entry of entries) {
const width = entry.contentBoxSize[0].inlineSize;
entry.target.style.setProperty("--columns", width > 600 ? 3 : 1);
}
});
});
observer.observe(grid);The change now lands one frame later, which removes the error. If the change resizes the element every time, though, the loop still runs, just once per frame instead of inside one.
Fix 2: do nothing when the size has not changed
Most loops come from code that writes a size even when nothing changed, or that reacts to its own change. Remember what you set and skip repeats:
const lastWidth = new WeakMap();
const observer = new ResizeObserver((entries) => {
for (const entry of entries) {
const width = Math.round(entry.contentBoxSize[0].inlineSize);
if (lastWidth.get(entry.target) === width) continue;
lastWidth.set(entry.target, width);
layoutFor(entry.target, width);
}
});Fix 3: in React, set state only when the size changes
A size hook that stores the size in state is a common source. Each callback sets state, the component re-renders, the new content changes the size, and the callback fires again.
function useElementSize(ref) {
const [size, setSize] = useState({ width: 0, height: 0 });
useLayoutEffect(() => {
const el = ref.current;
if (!el) return;
const observer = new ResizeObserver(([entry]) => {
const width = Math.round(entry.contentRect.width);
const height = Math.round(entry.contentRect.height);
setSize((prev) =>
prev.width === width && prev.height === height ? prev : { width, height }
);
});
observer.observe(el);
return () => observer.disconnect();
}, [ref]);
return size;
}Returning prev when nothing changed lets React skip the render. Also check that rendering with the new size cannot change the size of the observed element itself. If it can, observe a parent whose size does not depend on the content. Stop a ResizeObserver feedback loop with a useElementSize hook is this exact problem as an exercise.
Fix 4: break the loop with CSS
Often the cycle is "content grows, so the container grows, so the content changes again". Give the observed element a size that does not depend on its content, such as a fixed or percentage width, or overflow: hidden so new content cannot push it wider. Then the observer has nothing new to react to.
Filtering it out
If you have confirmed the loop settles, you may filter the message out of your tools. webpack-dev-server's client.overlay.runtimeErrors accepts a function that decides which runtime errors to show, and most error trackers have an ignore list. Filter by the exact message, never all errors.
Common follow-up questions
Why does it only happen sometimes?
It depends on timing and sizes: window width, fonts loading, scrollbars appearing. A layout that settles in one frame at one width may need two at another.
Is "ResizeObserver loop limit exceeded" the same thing?
People search both wordings. The current spec, and MDN, use "loop completed with undelivered notifications", and that is the condition this page covers.
Does requestAnimationFrame add lag?
Yes, one frame. For layout work that is usually invisible, and it is better than a flash of broken layout.
Should I wrap the callback in try/catch?
It will not help. The message is reported by the browser after your callback returns, not thrown from inside it.
Mistakes to avoid
Hiding every
windowerror to make this one go awayWriting a size or setting state in the callback when the value has not changed
Observing the same element whose size the callback changes
Wrapping the work in
requestAnimationFrameand assuming the loop is gone, without checking that it stopsCalling
getBoundingClientRectin the callback after writing styles, which forces an extra layoutThe entry already has the size. See batch DOM reads and writes.
Sources
Practise it in code
Interviewers rarely stop at the definition. These questions open in an editor with tests.
- Stop a
ResizeObserverfeedback loop with auseElementSizehookMedium30 min - Batch DOM reads and writes to fix layout thrashingMedium35 min
- Implement a responsive masonry layout using measured item heightsMedium45 min
- Implement a virtualized grid with variable row heights, overscan, and scroll restorationHard75 min
- Build a read-more toggle that clamps text to a few lines and appears only when the text overflowsEasy20 min