Skip to content

ResizeObserver infinite loop causes null being logged #9285

@Janpot

Description

@Janpot

Describe the bug

When certain errors, like "ResizeObserver loop completed with undelivered notifications" happen, null is printed to stderr with absolutely no clues about what's going on.

Reproduction

it("foo", async () => {
  const divElem = document.createElement("div");
  divElem.style.width = "100px";
  divElem.style.height = "100px";
  document.body.appendChild(divElem);

  const resizeObserver = new ResizeObserver((entries) => {
    for (const entry of entries) {
      entry.target.style.width = `${entry.contentBoxSize[0].inlineSize + 10}px`;
    }
  });

  resizeObserver.observe(divElem);
  await new Promise((resolve) => setTimeout(resolve, 1000));
  resizeObserver.unobserve(divElem);
});

Causes

...
stderr | test/suite.test.ts > foo
null
...

Repro: https://github.com/Janpot/vitest-observer-loop-repro/

Run pnpm test:run

System Info

System:
    OS: macOS 14.6.1
    CPU: (8) arm64 Apple M1
    Memory: 76.13 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.11.1 - ~/.nvm/versions/node/v24.11.1/bin/node
    npm: 11.6.2 - ~/.nvm/versions/node/v24.11.1/bin/npm
    pnpm: 10.13.1 - ~/.nvm/versions/node/v24.11.1/bin/pnpm
  Browsers:
    Safari: 17.6
  npmPackages:
    @vitest/browser-playwright: ^4.0.16 => 4.0.16 
    @vitest/ui: latest => 4.0.16 
    vite: latest => 7.3.0 
    vitest: latest => 4.0.16

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: browserIssues and PRs related to the browser runnerp3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions