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

Callback was already called. #16

Closed
gajus opened this issue Apr 20, 2018 · 4 comments
Closed

Callback was already called. #16

gajus opened this issue Apr 20, 2018 · 4 comments

Comments

@gajus
Copy link

gajus commented Apr 20, 2018

It appears that csso-webpack-plugin has some sort of concurrency condition:

/dev/node_modules/async/dist/async.js:955
        if (fn === null) throw new Error("Callback was already called.");
                         ^

Error: Callback was already called.
    at /dev/node_modules/async/dist/async.js:955:32
    at /dev/node_modules/csso-webpack-plugin/lib/index.js:185:32
    at /dev/node_modules/async/dist/async.js:3096:16
    at eachOfArrayLike (/dev/node_modules/async/dist/async.js:1055:9)
    at eachOf (/dev/node_modules/async/dist/async.js:1103:5)
    at Object.eachLimit (/dev/node_modules/async/dist/async.js:3158:5)
    at /dev/node_modules/csso-webpack-plugin/lib/index.js:118:37
    at /dev/node_modules/async/dist/async.js:3096:16
    at eachOfArrayLike (/dev/node_modules/async/dist/async.js:1055:9)
    at eachOf (/dev/node_modules/async/dist/async.js:1103:5)
    at Object.eachLimit (/dev/node_modules/async/dist/async.js:3158:5)
    at Compilation.<anonymous> (/dev/node_modules/csso-webpack-plugin/lib/index.js:117:33)
    at next (/dev/node_modules/tapable/lib/Tapable.js:204:14)
    at Compilation.<anonymous> (/dev/node_modules/babel-minify-webpack-plugin/dist/index.js:102:7)
    at next (/dev/node_modules/tapable/lib/Tapable.js:204:14)
    at Compilation.compilation.plugin (/dev/node_modules/babel-webpack-plugin/index.js:93:5)
    at Compilation.applyPluginsAsyncSeries (/dev/node_modules/tapable/lib/Tapable.js:206:13)
    at applyPluginsAsync.err (/dev/node_modules/webpack/lib/Compilation.js:663:10)
    at next (/dev/node_modules/tapable/lib/Tapable.js:202:11)
    at Compilation.<anonymous> (/dev/node_modules/extract-text-webpack-plugin/dist/index.js:275:11)
    at Compilation.applyPluginsAsyncSeries (/dev/node_modules/tapable/lib/Tapable.js:206:13)
    at applyPluginsAsyncSeries (/dev/node_modules/webpack/lib/Compilation.js:659:9)
    at next (/dev/node_modules/tapable/lib/Tapable.js:202:11)
    at /dev/node_modules/extract-text-webpack-plugin/dist/index.js:244:13
    at /dev/node_modules/async/dist/async.js:473:16
    at iteratorCallback (/dev/node_modules/async/dist/async.js:1050:13)
    at /dev/node_modules/async/dist/async.js:958:16
    at /dev/node_modules/extract-text-webpack-plugin/dist/index.js:227:15
    at /dev/node_modules/async/dist/async.js:473:16
    at eachOfArrayLike (/dev/node_modules/async/dist/async.js:1043:9)

It is a large project. I get this inconsistently. No clue what could trigger it.

The only configuration I have is:

new CssoWebpackPlugin({
    beforeCompress (ast, options) {
      options.usage = {
        scopes: getScopes(ast)
      };
    }
  })

Specifications

  • CSSO Plugin version: v1.0.0-beta.12
  • Webpack version: v3.11.0
  • CSSO version: v3.5.0
  • Node + npm versions: v9.8.0 and v5.6.0

/cc @zoobestik

@gajus
Copy link
Author

gajus commented Apr 20, 2018

I figured as much as that the callback is called multiple times.

The subject file to blame is manifest file, which is a file created using https://www.npmjs.com/package/webpack-assets-manifest.

@gajus
Copy link
Author

gajus commented Apr 20, 2018

The issue arrises when the callback throws an error,

return callback();

In that case, the async is not completed and you arrive at:

return callback();

The actual error is:

Error: original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.

I have not figured out whether this is directly related to csso-webpack-plugin.

@gajus
Copy link
Author

gajus commented Apr 20, 2018

It looks like error is only triggered when I add babel-minify-webpack-plugin plugin. Somehow the latter messes up sourcemap mapping.

Here is a relevant issue.

webpack-contrib/babel-minify-webpack-plugin#68

Seems that csso-webpack-plugin is not to blame here.

However, csso-webpack-plugin logic needs to be fixed to prevent the callback being called twice. Otherwise the underlying error is masked.

zoobestik added a commit that referenced this issue Dec 13, 2019
@zoobestik
Copy link
Owner

async dropped from v2.0.0, let me know, if you will help problems with new versions.

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

2 participants