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

esbuild 0.12.12 Cannot be used in custom multi thread app. #1406

Closed
rizrmd opened this issue Jun 29, 2021 · 1 comment · Fixed by #1411
Closed

esbuild 0.12.12 Cannot be used in custom multi thread app. #1406

rizrmd opened this issue Jun 29, 2021 · 1 comment · Fixed by #1411

Comments

@rizrmd
Copy link

rizrmd commented Jun 29, 2021

When running esbuild 0.12.12 as a child worker, esbuild throw this:

node:internal/event_target:641
  process.nextTick(() => { throw err; });
                           ^
TypeError [Error]: Cannot read property 'workerPort' of undefined
    at startSyncServiceWorker (/Users/riz/Documents/base/node_modules/esbuild/lib/main.js:1888:46)
    at Object.<anonymous> (/Users/riz/Documents/base/node_modules/esbuild/lib/main.js:1924:3)
    at Module._compile (node:internal/modules/cjs/loader:1095:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1124:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:816:12)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:93:18)
    at Object.<anonymous> (/Users/riz/Documents/base/pkgs/builder/build/index.js:37:33)
    at Module._compile (node:internal/modules/cjs/loader:1095:14)
Emitted 'error' event on Thread instance at:
    at Thread.[kOnErrorMessage] (node:internal/worker:298:10)
    at Thread.[kOnMessage] (node:internal/worker:309:37)
    at MessagePort.<anonymous> (node:internal/worker:210:57)
    at MessagePort.[nodejs.internal.kHybridDispatch] (node:internal/event_target:461:20)
    at MessagePort.exports.emitMessage (node:internal/per_context/messageport:23:28)

esbuild 0.12.9 works fine, it shows error only when I update to 0.12.12.

I can workaround this error by disabling worker thread optimization.
By changing node_modules/esbuild/lib/main.js:1923 into this:

if (false && worker_threads && !worker_threads.isMainThread) {
  startSyncServiceWorker();
}

And esbuild is humming again.

@evanw
Copy link
Owner

evanw commented Jun 29, 2021

You can disable it by either using an earlier version of esbuild or by setting the environment variable ESBUILD_WORKER_THREADS=0 before running esbuild. I can't look at this right now but may have time to look at this later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants