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

Window can not be created in Bun from version 14.5.1 and higher #1415

Open
Dyskal opened this issue Apr 24, 2024 · 3 comments
Open

Window can not be created in Bun from version 14.5.1 and higher #1415

Dyskal opened this issue Apr 24, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@Dyskal
Copy link

Dyskal commented Apr 24, 2024

Describe the bug
When using new Window() in a Bun environment, the script crash

To Reproduce
Steps to reproduce the behavior:

  1. Install happy-dom version 14.5.1 or higher
  2. Import Window and run new Window()
  3. Run the script with bun bun ./index.js
  4. See error

Expected behavior
The program should run correctly

Screenshots
If applicable, add screenshots to help explain your problem.

Device:

  • OS: Windows 11
  • Bun version: 1.1.4
  • Version: 14.5.1 to latest

Additional context

26 |                 resolve();
27 |             }
28 |             else {
29 |                 this.readyStateCallbacks.push(resolve);
30 |                 if (this.totalTasks === 0 && !this.immediate) {
31 |                     this.immediate = this.window.requestAnimationFrame(this.endTask.bind(this));
                                          ^
TypeError: this.window.requestAnimationFrame is not a function. (In 'this.window.requestAnimationFrame(this.endTask.bind(this))', 'this.window.requestAnimationFrame' is undefined)
      at ${PROJECT_ROOT}\node_modules\happy-dom\lib\nodes\document\DocumentReadyStateManager.js:31:38
      at new Promise (:1:21)
      at waitUntilComplete (${PROJECT_ROOT}\node_modules\happy-dom\lib\nodes\document\DocumentReadyStateManager.js:24:16)
      at new BrowserWindow (${PROJECT_ROOT}\node_modules\happy-dom\lib\window\BrowserWindow.js:545:9)
      at new Window (${PROJECT_ROOT}\node_modules\happy-dom\lib\window\Window.js:36:9)
@Dyskal Dyskal added the bug Something isn't working label Apr 24, 2024
@Dyskal
Copy link
Author

Dyskal commented Apr 24, 2024

Also reproductible on bun 1.1.4 in wsl2

@twlite
Copy link

twlite commented May 17, 2024

I am also having the same problem but in my case I see two errors. I am using happy-dom@14.11.0

26 |                 resolve();
27 |             }
28 |             else {
29 |                 this.readyStateCallbacks.push(resolve);
30 |                 if (this.totalTasks === 0 && !this.immediate) {
31 |                     this.immediate = this.window.requestAnimationFrame(this.endTask.bind(this));
                                          ^
TypeError: this.window.requestAnimationFrame is not a function. (In 'this.window.requestAnimationFrame(this.endTask.bind(this))', 'this.window.requestAnimationFrame' is undefined)
      at PROJECT_ROOT\node_modules\happy-dom\lib\nodes\document\DocumentReadyStateManager.js:31:38
      at new Promise (:1:21)
      at waitUntilComplete (PROJECT_ROOT\node_modules\happy-dom\lib\nodes\document\DocumentReadyStateManager.js:24:16)
      at new BrowserWindow (PROJECT_ROOT\node_modules\happy-dom\lib\window\BrowserWindow.js:554:9)
      at new Window (PROJECT_ROOT\node_modules\happy-dom\lib\window\Window.js:36:9)
      at createDocument (PROJECT_ROOT\src\document.ts:12:18)
      at new UI (PROJECT_ROOT\src\index.ts:9:29)
      at PROJECT_ROOT\test\index.tsx:6:12
184 |             return false;
185 |         }
186 |         if (ancestorNode === referenceNode) {
187 |             return true;
188 |         }
189 |         if (!ancestorNode[PropertySymbol.childNodes].length) {
                   ^
TypeError: undefined is not an object (evaluating 'ancestorNode[PropertySymbol.childNodes].length')
      at isInclusiveAncestor (PROJECT_ROOT\node_modules\happy-dom\lib\nodes\node\NodeUtility.js:189:14)
      at appendChild (PROJECT_ROOT\node_modules\happy-dom\lib\nodes\node\NodeUtility.js:24:52)
      at appendChild (PROJECT_ROOT\node_modules\happy-dom\lib\nodes\element\ElementUtility.js:52:13)
      at insertNode (PROJECT_ROOT\src\document.ts:48:9)
      at insertExpression (PROJECT_ROOT\node_modules\solid-js\universal\dist\universal.js:85:9)
      at PROJECT_ROOT\node_modules\solid-js\universal\dist\universal.js:224:9
      at createRoot (PROJECT_ROOT\node_modules\solid-js\dist\server.js:58:14)
      at render (PROJECT_ROOT\node_modules\solid-js\universal\dist\universal.js:222:7)
      at render (PROJECT_ROOT\src\index.ts:33:5)
      at PROJECT_ROOT\test\index.tsx:18:16

Bun v1.1.8 (Windows x64)

@yaroslav-ilin
Copy link

I think it's up to the Bun.js team to fix this, they seem to be aware:

There is a bug with this value for contextified options not having the correct prototype.

Source: https://bun.sh/docs/runtime/nodejs-apis#node-vm

Probably, this is the issue oven-sh/bun#4205.

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

No branches or pull requests

3 participants