Skip to content

This require call is not allowed because the transitive dependency "node-modules-polyfills:node:worker_threads" contains a top-level await #282

@ffMathy

Description

@ffMathy

Issue description

✘ [ERROR] This require call is not allowed because the transitive dependency "node-modules-polyfills:node:worker_threads" contains a top-level await

    node_modules/undici/lib/web/websocket/events.js:6:32:
      6 │ const { MessagePort } = require('node:worker_threads')
        ╵                                 ~~~~~~~~~~~~~~~~~~~~~

  The file "node-modules-polyfills-commonjs:node:worker_threads" imports the file
  "node-modules-polyfills:node:worker_threads" here:

    node-modules-polyfills-commonjs:node:worker_threads:1:14:
      1 │ export * from 'node:worker_threads'
        ╵               ~~~~~~~~~~~~~~~~~~~~~

  The top-level await in "node-modules-polyfills:node:worker_threads" is here:

    node-modules-polyfills:node:worker_threads:97:49:
      97 │   ([{ threadId, workerData, environmentData }] = await once(parentPort, 'message'));
         ╵                                                  ~~~~~


 NX   Build failed with 1 error:

node_modules/undici/lib/web/websocket/events.js:6:32: ERROR: This require call is not allowed because the transitive dependency "node-modules-polyfills:node:worker_threads" contains a top-level await
Error: Build failed with 1 error:
node_modules/undici/lib/web/websocket/events.js:6:32: ERROR: This require call is not allowed because the transitive dependency "node-modules-polyfills:node:worker_threads" contains a top-level await
    at failureErrorWithLog (/workspaces/WATS/node_modules/esbuild/lib/main.js:1476:15)
    at /workspaces/WATS/node_modules/esbuild/lib/main.js:945:25
    at /workspaces/WATS/node_modules/esbuild/lib/main.js:1354:9
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Code sample

Code is under NDA, and I tried spending hours creating a repro with no luck.

Package version

1.6.7

Node.js version

v20.17.0

Operating system

No response

I have tested this issue on a next release

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions