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

Defining importScriptsTransform causes DataCloneError #105

Open
emattias opened this issue Oct 7, 2020 · 5 comments
Open

Defining importScriptsTransform causes DataCloneError #105

emattias opened this issue Oct 7, 2020 · 5 comments

Comments

@emattias
Copy link
Contributor

emattias commented Oct 7, 2020

After updating ember to 3.21.3 we start getting a DataCloneError when the importScriptsTransform function is defined in ember-cli-build

JSReloader watches js|ts|hbs
⠙ building... [Babel: ember-cli-workbox > applyPatches]error: --------------------------------------------------------------------------
error: An uncaught YUIDoc error has occurred, stack trace given below
error: --------------------------------------------------------------------------
error: DataCloneError: (importScripts) => {
      return importScripts.map((importScript) => {
        return ENV.EMBER_ASSETS_ROOT_PA...<omitted>... } could not be cloned.
    at Worker.postMessage (internal/worker.js:279:23)
    at Worker.worker.send (/Users/emattias/repos/ember-cli-workbox/node_modules/broccoli-babel-transpiler/node_modules/workerpool/lib/WorkerHandler.js:77:10)
    at Array.forEach (<anonymous>)
    at dispatchQueuedRequests (/Users/emattias/repos/ember-cli-workbox/node_modules/broccoli-babel-transpiler/node_modules/workerpool/lib/WorkerHandler.js:240:21)
    at Worker.<anonymous> (/Users/emattias/repos/ember-cli-workbox/node_modules/broccoli-babel-transpiler/node_modules/workerpool/lib/WorkerHandler.js:195:7)
    at Worker.emit (events.js:315:20)
    at Worker.EventEmitter.emit (domain.js:482:12)
    at MessagePort.<anonymous> (internal/worker.js:192:55)
    at MessagePort.emit (events.js:315:20)
    at MessagePort.EventEmitter.emit (domain.js:482:12)
error: --------------------------------------------------------------------------

If you cant have functions in the app config is there some other way to send the function to the addon? Here's a workaround used by trackJs for a similar problem.

@rwjblue
Copy link

rwjblue commented Oct 7, 2020

This happens in the browser (not the build) right? What is the full stack trace? Why is it trying to postMessage the config?

@rwjblue
Copy link

rwjblue commented Oct 7, 2020

Hmm, actually seems to be in node-land:

https://github.com/nodejs/node/blob/v14.13.0/lib/internal/worker.js#L298

IS that the full stack trace you provided above? I would expect at least a little more context there...

@emattias
Copy link
Contributor Author

emattias commented Oct 7, 2020

I updated it with more context and stack trace

@rwjblue
Copy link

rwjblue commented Oct 7, 2020

Nice, that is really useful! I had originally gotten confused by the postMessage usage (within a project that is actually reasonably going to use postMessage anyways due to the SW aspect), but this is actually just an issue with babel transpilation. By default broccoli-babel-transpiler (which is what ember-cli-babel uses) uses workerpool to parallelize the babel build (either via threads if on new enough Node, or processes). It seems like the ember-cli-workbox options from ember-cli-build.js is being used as part of the configuration for that babel build (but it doesn't really seem like it ought to be) which is what is causing this error.

Can you whip up a reproduction that is largely a npx ember-cli new test-app-here that I could use to help debug?

@adrigzr
Copy link
Contributor

adrigzr commented Oct 7, 2020

Hi @emattias, we moved that option from config/environment to the ember-cli-build file for that very reason. I didn't test it on 3.21 but on 3.16 it is working fine.

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

No branches or pull requests

3 participants