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

TypeError: Cannot read properties of null (reading 'Symbol(asyncTaskManager)') #1669

Closed
wojtekmaj opened this issue Jan 7, 2025 · 1 comment · Fixed by #1673
Closed

TypeError: Cannot read properties of null (reading 'Symbol(asyncTaskManager)') #1669

wojtekmaj opened this issue Jan 7, 2025 · 1 comment · Fixed by #1673
Assignees
Labels
bug Something isn't working

Comments

@wojtekmaj
Copy link
Contributor

Describe the bug

In our unit tests, testing an iframe with YouTube embed, we suddenly started getting the following error, without obvious changes to the test code/code being tested:

TypeError: Cannot read properties of null (reading 'Symbol(asyncTaskManager)')
    at Response.text (file:///agent/_work/1/s/.yarn/cache/happy-dom-npm-15.11.1-f040f1386c-10c0.zip/node_modules/happy-dom/src/fetch/Response.ts:206:40)
    at Function.navigate (file:///agent/_work/1/s/.yarn/cache/happy-dom-npm-15.11.1-f040f1386c-10c0.zip/node_modules/happy-dom/src/browser/utilities/BrowserFrameNavigator.ts:222:34)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)

While the version of happy-dom we're using is out of date, it looks like the lines in question remained unchanged since:

const browserFrame = new WindowBrowserContext(window).getBrowserFrame();
const asyncTaskManager = browserFrame[PropertySymbol.asyncTaskManager];

If we look at the code, it becomes apparent that indeed, browserFrame can be null:

public getBrowserFrame(): IBrowserFrame | null {

For some reason null check isn't there and TypeScript does not complain.

To Reproduce

I'm so sorry, no reproducible example just yet, as I can only reproduce that on CI. Working on it, but maaaaybe the details provided will be enough?

Expected behavior

No crash

Device:

  • OS: [e.g. iOS]: Node.js
  • Browser [e.g. chrome, safari] n/a
  • Version [e.g. 22] 22
@wojtekmaj wojtekmaj added the bug Something isn't working label Jan 7, 2025
@capricorn86 capricorn86 self-assigned this Jan 7, 2025
capricorn86 added a commit that referenced this issue Jan 7, 2025
capricorn86 added a commit that referenced this issue Jan 7, 2025
@capricorn86
Copy link
Owner

Thank you for reporting @wojtekmaj! 🙂

The reason is most likely due to browser frame not being available during tear down of the Window. It is hard to cover all cases for this as the Javascript often continues to run and can't be interrupted while the window is closing down.

I have added null checks for this case in Response now in v16.4.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
2 participants