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

Bug: DOMException error when running parcel #23522

Closed
marvinhagemeister opened this issue Apr 24, 2024 · 5 comments
Closed

Bug: DOMException error when running parcel #23522

marvinhagemeister opened this issue Apr 24, 2024 · 5 comments
Labels
bug Something isn't working correctly node compat

Comments

@marvinhagemeister
Copy link
Contributor

marvinhagemeister commented Apr 24, 2024

Steps to reproduce

  1. Create index.html file with these contents:
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8"/>
    <title>My First Parcel App</title>
  </head>
  <body>
    <h1>Hello, World!</h1>
  </body>
</html>
  1. Run npm init -y && npm i parcel
  2. Run DENO_FUTURE=1 deno run -A npm:parcel index.html

Error

DOMException: #<Object> could not be cloned.
    at new DOMException (ext:deno_web/01_dom_exception.js:116:20)
    at ext:deno_web/13_message_port.js:389:11
    at Object.serialize (ext:core/01_core.js:672:14)
    at serializeJsMessageData (ext:deno_web/13_message_port.js:388:31)
    at new NodeWorker (node:worker_threads:129:38)
    at ThreadsWorker.start (file:///Users/marvinh/dev/test/deno-parcel/node_modules/.pnpm/@parcel+workers@2.12.0_@parcel+core@2.12.0/node_modules/@parcel/workers/lib/threads/ThreadsWorker.js:38:19)
    at Worker.fork (file:///Users/marvinh/dev/test/deno-parcel/node_modules/.pnpm/@parcel+workers@2.12.0_@parcel+core@2.12.0/node_modules/@parcel/workers/lib/Worker.js:90:23)
    at WorkerFarm.startChild (file:///Users/marvinh/dev/test/deno-parcel/node_modules/.pnpm/@parcel+workers@2.12.0_@parcel+core@2.12.0/node_modules/@parcel/workers/lib/WorkerFarm.js:229:12)
    at WorkerFarm.startMaxWorkers (file:///Users/marvinh/dev/test/deno-parcel/node_modules/.pnpm/@parcel+workers@2.12.0_@parcel+core@2.12.0/node_modules/@parcel/workers/lib/WorkerFarm.js:389:14)
    at new WorkerFarm (file:///Users/marvinh/dev/test/deno-parcel/node_modules/.pnpm/@parcel+workers@2.12.0_@parcel+core@2.12.0/node_modules/@parcel/workers/lib/WorkerFarm.js:136:10)

Related #23281

Version: Deno 1.42.4 (git 5294885 2024-04-24)

@marvinhagemeister marvinhagemeister added bug Something isn't working correctly node compat labels Apr 24, 2024
@bartlomieju
Copy link
Member

I can't reproduce it... When I run parcel like that I get resolution errors:

Error: Cannot find module '@parcel/config-default'
Require stack:
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.12.0/lib/cli.js
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.12.0/lib/bin.js
    at Function.Module._resolveFilename (node:module:566:15)
    at Function.resolve (node:module:712:19)
    at run (file:///Users/ib/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/ib/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.12.0/lib/cli.js",
    "/Users/ib/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.12.0/lib/bin.js"
  ]
}

How do you get to that error?

@marvinhagemeister
Copy link
Contributor Author

Whoops, you're right. It looks like I had parcel installed via npm. I'll update the reproduction instructions.

@bartlomieju
Copy link
Member

I tracked down the problem to the fact that env is passed to worker on startup to be sent to the worker environment. It appears that env is not a regular object (but maybe some kind of proxy) that causes this error. Opened: #23536

That said, even if we fix this, running this program still completely freezes the terminal and you need to manually kill the process from a separate terminal.

@marvinhagemeister
Copy link
Contributor Author

@bartlomieju Looks like I closed #23281 prematurely

bartlomieju added a commit that referenced this issue Apr 24, 2024
Most common argument to `env` option for `worker_threads.Worker` will be
`process.env`.

In Deno `process.env` is a `Proxy` which can't be cloned using
structured clone algorithm.

So to be safe, I'm creating a copy of actual object before it's sent to
the worker thread.

Ref #23522
@bartlomieju
Copy link
Member

Closing this one, let's continue in #23281

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 compat
Projects
None yet
Development

No branches or pull requests

2 participants