★ wanayoo — archive 1999 https://github.com/JS-DevTools/simplifyify/issues/21Nouvelle recherche | Portail wanayoo
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

Task completion callback called too many times #21

Open
ozgrozer opened this issue Jun 9, 2017 · 2 comments
Open

Task completion callback called too many times #21

ozgrozer opened this issue Jun 9, 2017 · 2 comments
Labels

Comments

@ozgrozer
Copy link

@ozgrozer ozgrozer commented Jun 9, 2017

I'm using Simplifyify with Gulp like that.

gulp.task("simplifyify", function(done) {
  simplifyify("app/dev/js/*.js",
    {
      outfile: "app/prod/js/*.js",
      debug: true,
      minify: false
    })
    .on("end", function() {
      done();
    })
    .on("error", function(err) {
      done(err);
    });
});

If there is just one file in the source folder, Simplifyify works perfectly. But if there are two or more files in the source folder Simplifyify gives those errors.

'simplifyify' errored after 845 ms
[16:59:35] Error: task completion callback called too many times
    at finish (/path/electron/node_modules/orchestrator/lib/runTask.js:15:10)
    at cb (/path/electron/node_modules/orchestrator/lib/runTask.js:29:3)
    at EventEmitter.<anonymous> (/path/electron/gulpfile.js:62:4)
    at emitOne (events.js:96:13)
    at EventEmitter.emit (events.js:191:7)
    at Browserify.browserify.on (/path/electron/node_modules/simplifyify/lib/write-bundles.js:175:12)
    at emitNone (events.js:91:20)
    at Browserify.emit (events.js:188:7)
    at browserify.postProcessing.then (/path/electron/node_modules/simplifyify/lib/write-bundles.js:228:22)

I couldn't find a helpful answer. Any solution?

@JamesMessinger
Copy link
Member

@JamesMessinger JamesMessinger commented Jun 9, 2017

Simplifyify just propagates events from Browserify. If you have multiple entry files, then there will be multiple Browserify instances propagating events, which is why any of the events can fire multiple times. So, for example, if you have 5 entry files, then you'd need to handle the "end" event like this:

    .on("end", function() {
        finished++;
        if (finished === 5) {
            done();
        }
    })

However, I think you'll agree that this is neither an elegant nor a straightforward solution. Simplifyify should emit its own synthetic event when all of the bundles have finished building. Then you could simply handle that event instead of the "end" event.

    .on("finish", function() {
        done();
    })
@ozgrozer
Copy link
Author

@ozgrozer ozgrozer commented Jun 10, 2017

Both of them don't work with Gulp Watch.

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.