Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lots of NPE errors logged by MutationListener #1436

Closed
thaggie opened this issue May 14, 2024 · 1 comment · Fixed by #1437
Closed

Lots of NPE errors logged by MutationListener #1436

thaggie opened this issue May 14, 2024 · 1 comment · Fixed by #1437
Labels
bug Something isn't working

Comments

@thaggie
Copy link

thaggie commented May 14, 2024

We're using @swc/jest with @happy-dom/jest-environment@14.7.1 / happy-dom@14.7.1, (upgrading to X.10.2 doesn't seem to help).

We're seeing a lot of errors logged from MutationListener which is causing a lot of noise in our unit test logs.

[my-project]:     console.error
[my-project]:       TypeError: Cannot read properties of null (reading 'length')
[my-project]:           at /builds/my-project/node_modules/happy-dom/src/mutation-observer/MutationListener.ts:55:16
[my-project]:           at /builds/my-project/node_modules/happy-dom/src/window/BrowserWindow.ts:1021:49
[my-project]:           at Function.captureError (/builds/my-project/node_modules/happy-dom/src/window/WindowErrorUtility.ts:29:13)
[my-project]:           at Timeout._onTimeout (/builds/my-project/node_modules/happy-dom/src/window/BrowserWindow.ts:1021:24)
[my-project]:           at listOnTimeout (node:internal/timers:569:17)
[my-project]:           at processTimers (node:internal/timers:512:7)
[my-project]: 
[my-project]:       at Function.dispatchError (node_modules/happy-dom/src/window/WindowErrorUtility.ts:57:45)
[my-project]:       at Function.captureError (node_modules/happy-dom/src/window/WindowErrorUtility.ts:31:9)
[my-project]:       at Timeout._onTimeout (node_modules/happy-dom/src/window/BrowserWindow.ts:1021:24)
@thaggie thaggie added the bug Something isn't working label May 14, 2024
@capricorn86
Copy link
Owner

Thank you for reporting @thaggie! 🙂

It seems like some code continues to run after the environment was shut down (and the Window and MutationObservers has been destroyed).

I have added a fix that checks if it has been destroyed, which should solve your problem.

You can read more about the release here:
https://github.com/capricorn86/happy-dom/releases/tag/v14.10.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants