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

Support Parcel #20613

Closed
birkskyum opened this issue Sep 21, 2023 · 6 comments · Fixed by #25439
Closed

Support Parcel #20613

birkskyum opened this issue Sep 21, 2023 · 6 comments · Fixed by #25439
Assignees
Labels
bug Something isn't working correctly node API polyfill Related to various "node:*" modules APIs node compat

Comments

@birkskyum
Copy link
Contributor

Platform

Darwin 22.6.0 arm64 arm

Version

deno 1.37.0

Repro

Make an index.html

<html>
  <head>
    <title>My First Parcel App</title>
  </head>
  <body>
    <h1>Hello, World!</h1>
  </body>
</html>

Run it with deno

  • deno run -A npm:parcel index.html

Expected

Server running at http://localhost:1234
✨ Built in 494ms

Actual

➜ deno run -A npm:parcel index.html
Error: Not implemented: v8.deserialize
    at notImplemented (ext:deno_node/_utils.ts:9:9)
    at deserialize (node:v8:62:3)
    at deserialize (file:///Users/admin/repos/deno-parcel/node_modules/.deno/@parcel+core@2.9.3/node_modules/@parcel/core/lib/serializer.js:204:48)
    at loadRequestGraph (file:///Users/admin/repos/deno-parcel/node_modules/.deno/@parcel+core@2.9.3/node_modules/@parcel/core/lib/RequestTracker.js:744:52)
    at eventLoopTick (ext:core/01_core.js:183:11)
    at async Function.init (file:///Users/admin/repos/deno-parcel/node_modules/.deno/@parcel+core@2.9.3/node_modules/@parcel/core/lib/RequestTracker.js:718:17)
    at async Parcel._init (file:///Users/admin/repos/deno-parcel/node_modules/.deno/@parcel+core@2.9.3/node_modules/@parcel/core/lib/Parcel.js:178:28)
    at async Parcel.watch (file:///Users/admin/repos/deno-parcel/node_modules/.deno/@parcel+core@2.9.3/node_modules/@parcel/core/lib/Parcel.js:228:7)
    at async run (file:///Users/admin/repos/deno-parcel/node_modules/.deno/parcel@2.9.3/node_modules/parcel/lib/cli.js:286:9)
error: Uncaught (in worker "$DENO_STD_NODE_WORKER_THREAD") (in promise) Error: Only create ThreadsChild instances in a worker!
    at new ThreadsChild (file:///Users/admin/repos/deno-parcel/node_modules/.deno/@parcel+workers@2.9.3/node_modules/@parcel/workers/lib/threads/ThreadsChild.js:34:13)
    at new Child (file:///Users/admin/repos/deno-parcel/node_modules/.deno/@parcel+workers@2.9.3/node_modules/@parcel/workers/lib/child.js:65:18)
    at Object.<anonymous> (file:///Users/admin/repos/deno-parcel/node_modules/.deno/@parcel+workers@2.9.3/node_modules/@parcel/workers/lib/threads/ThreadsChild.js:49:27)
    at Object.<anonymous> (file:///Users/admin/repos/deno-parcel/node_modules/.deno/@parcel+workers@2.9.3/node_modules/@parcel/workers/lib/threads/ThreadsChild.js:50:4)
    at Module._compile (node:module:733:34)
    at Object.Module._extensions..js (node:module:747:10)
    at Module.load (node:module:658:32)
    at Function.Module._load (node:module:539:12)
    at Module.require (node:module:677:19)
    at require (node:module:791:16)
@bartlomieju bartlomieju added bug Something isn't working correctly node compat labels Sep 22, 2023
@bartlomieju bartlomieju self-assigned this Sep 26, 2023
@bartlomieju
Copy link
Member

bartlomieju commented Sep 28, 2023

@birkskyum thanks for reporting. I can't seem to reproduce the problem you are facing, for me parcel is failing on resolution of some modules:

Error: Cannot find module '@parcel/config-default'
Require stack:
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.9.3/lib/cli.js
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.9.3/lib/bin.js
    at Function.Module._resolveFilename (node:module:624:15)
    at Function.resolve (node:module:794:19)
    at run (file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.9.3/lib/cli.js:217:28)
    at eventLoopTick (ext:core/01_core.js:197:13) {
  code: "MODULE_NOT_FOUND",
  requireStack: [
    "/Users/ib/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.9.3/lib/cli.js",
    "/Users/ib/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.9.3/lib/bin.js"
  ]
}

And if I use --node-modules-dir flag I get:

error: Uncaught (in worker "$DENO_STD_NODE_WORKER_THREAD") (in promise) Error: Only create ThreadsChild instances in a worker!
    at new ThreadsChild (file:///Users/ib/dev/try_parcel/node_modules/.deno/@parcel+workers@2.9.3/node_modules/@parcel/workers/lib/threads/ThreadsChild.js:34:13)
    at new Child (file:///Users/ib/dev/try_parcel/node_modules/.deno/@parcel+workers@2.9.3/node_modules/@parcel/workers/lib/child.js:65:18)
    at Object.<anonymous> (file:///Users/ib/dev/try_parcel/node_modules/.deno/@parcel+workers@2.9.3/node_modules/@parcel/workers/lib/threads/ThreadsChild.js:49:27)
    at Object.<anonymous> (file:///Users/ib/dev/try_parcel/node_modules/.deno/@parcel+workers@2.9.3/node_modules/@parcel/workers/lib/threads/ThreadsChild.js:50:4)
    at Module._compile (node:module:733:34)
    at Object.Module._extensions..js (node:module:747:10)
    at Module.load (node:module:658:32)
    at Function.Module._load (node:module:539:12)
    at Module.require (node:module:677:19)
    at require (node:module:791:16)
// more errors like this

(what I mean is that I can't hit that v8.deserialize error, the error coming from workers is legit one and I know how to fix it)

@birkskyum
Copy link
Contributor Author

birkskyum commented Sep 28, 2023

I tried updating to deno 1.37.1, and run again, and now I see the same output as you.

@bartlomieju
Copy link
Member

@birkskyum any chance you could try again with latest canary? We put a lot of effort into improving node:worker_threads module recently and I think this might now work correctly.

@birkskyum
Copy link
Contributor Author

birkskyum commented Mar 24, 2024

Fantastic work on pushing the compat! I get this now, so it could be it's very close for both Expo and Parcel:

➜ deno run -A npm:parcel index.html
TypeError: Cannot read properties of undefined (reading 'Symbol(Deno.internal.rid)')
    at TTY.#read (ext:deno_node/internal_binding/stream_wrap.ts:220:45)
    at TTY.readStart (ext:deno_node/internal_binding/stream_wrap.ts:90:17)
    at _tryReadStart (node:net:276:30)
    at ReadStream._read (node:net:856:7)
    at ReadStream.Readable.read (ext:deno_node/_stream.mjs:2999:16)
    at ReadStream.read (node:net:789:34)
    at resume_ (ext:deno_node/_stream.mjs:3349:16)
    at Array.processTicksAndRejections (ext:deno_node/_next_tick.ts:33:15)
    at eventLoopTick (ext:core/01_core.js:165:29)

@birkskyum
Copy link
Contributor Author

birkskyum commented Mar 30, 2024

Running with canary now gives this:

(base) birkskyum@Birks-MacBook-Pro deno-kitchensink % deno run -A npm:parcel index.html
Error: Cannot find module '@parcel/config-default'
Require stack:
- /Users/birkskyum/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.12.0/lib/cli.js
- /Users/birkskyum/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.12.0/lib/bin.js
    at Function.Module._resolveFilename (node:module:609:15)
    at Function.resolve (node:module:779:19)
    at run (file:///Users/birkskyum/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.12.0/lib/cli.js:217:28)
    at eventLoopTick (ext:core/01_core.js:207:9) {
  code: "MODULE_NOT_FOUND",
  requireStack: [
    "/Users/birkskyum/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.12.0/lib/cli.js",
    "/Users/birkskyum/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.12.0/lib/bin.js"
  ]

I figured I'd try installing parcel with npm and try running it as a "script" in package json, with and without the byonm flag in deno.js, but then I hit this, and the terminal froze completely, to the point where I could not even abort it.

Task compress parcel index.html

Related

@bartlomieju bartlomieju added the node API polyfill Related to various "node:*" modules APIs label Mar 31, 2024
@bartlomieju bartlomieju removed their assignment Mar 31, 2024
@zzz6519003
Copy link

deno deploy + parcel template pls

@nathanwhit nathanwhit self-assigned this Aug 28, 2024
nathanwhit added a commit that referenced this issue Aug 28, 2024
…#25243)

Fixes #23281. Part of #20613.

We were emitting the `online` event in the constructor, so the caller
could never receive it (since there was no time for them to add a
listener). Instead, emit the event where it's intended – after the
worker is initialized.

---

After this parcel no longer freezes, but still will fail due to other
bugs (which will be fixed in other PRs)
nathanwhit added a commit that referenced this issue Aug 28, 2024
…5245)

Part of #20613.

If a node addon is using the legacy `napi_module_register` on ctor
approach to module registration, we have to store the registered module
so that other threads can load the addon (because `napi_module_register`
will only be called once per process).
lucacasonato pushed a commit that referenced this issue Aug 29, 2024
…#25243)

Fixes #23281. Part of #20613.

We were emitting the `online` event in the constructor, so the caller
could never receive it (since there was no time for them to add a
listener). Instead, emit the event where it's intended – after the
worker is initialized.

---

After this parcel no longer freezes, but still will fail due to other
bugs (which will be fixed in other PRs)
lucacasonato pushed a commit that referenced this issue Aug 29, 2024
…5245)

Part of #20613.

If a node addon is using the legacy `napi_module_register` on ctor
approach to module registration, we have to store the registered module
so that other threads can load the addon (because `napi_module_register`
will only be called once per process).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node API polyfill Related to various "node:*" modules APIs node compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants