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 #6

Closed
franklinjavier opened this issue Jun 15, 2015 · 8 comments
Closed

Callback was already called #6

franklinjavier opened this issue Jun 15, 2015 · 8 comments

Comments

@franklinjavier
Copy link

When I try to use browserSync, I'm getting this error
This is my index.js

Any suggestions to fix it?
Cheer

$ node index.js 
/home/franklin/b0x/Projects/blog/node_modules/metalsmith-templates/node_modules/async/lib/async.js:22
            if (called) throw new Error("Callback was already called.");
                              ^
Error: Callback was already called.
    at /home/franklin/b0x/Projects/blog/node_modules/metalsmith-templates/node_modules/async/lib/async.js:22:31
    at /home/franklin/b0x/Projects/blog/node_modules/metalsmith-templates/lib/index.js:63:25
    at Function.exports.handlebars.render (/home/franklin/b0x/Projects/blog/node_modules/metalsmith-templates/node_modules/consolidate/lib/consolidate.js:499:5)
    at /home/franklin/b0x/Projects/blog/node_modules/metalsmith-templates/node_modules/consolidate/lib/consolidate.js:146:25
    at /home/franklin/b0x/Projects/blog/node_modules/metalsmith-templates/node_modules/consolidate/lib/consolidate.js:99:5
    at fs.js:336:14
    at FSReqWrap.oncomplete (fs.js:99:15)

@claycarpenter
Copy link

This issue seems to have been fixed by my PR #5 .

If you want to give it a try on your site, you can use this command:

npm install --save-dev git://github.com/claycarpenter/metalsmith-browser-sync#active-check

@franklinjavier
Copy link
Author

@claycarpenter thanks, but... Am I missing something?

npm install --save-dev git://github.com/claycarpenter/metalsmith-browser-sync#active-check
zsh: no matches found: git://github.com/claycarpenter/metalsmith-browser-sync#active-check

@franklinjavier
Copy link
Author

Now it worked. I changed the contents manually and it worked.
I'll have repeat this process until our friend accepts your PR.
Thanks mate @claycarpenter

@claycarpenter
Copy link

@franklinjavier great! I was just going to reply that I couldn't replicate the error and suggest you make the changes manually. Glad to hear it's working for you.

@franklinjavier
Copy link
Author

🍻

@franklinjavier
Copy link
Author

@claycarpenter every time I save a file, duplicates the quantity of posts.

@claycarpenter
Copy link

@franklinjavier As far as I can tell right now, this looks like an issue with metalsmith-collections when it's run multiple times without a fresh Metalsmith build. It's late and I'm sleepy and stupid, but it looks like the ms-collections plugin adds the matching files it finds to the global (Metalsmith) metadata each time it's run.

I made a very quick hack that fixed the problem by clearing out the metadata.posts collection before each metalsmith-collections run. The "plugin" looks like this:

    .use(function (files, metalsmith, done) {
        var metadata = metalsmith.metadata();
        delete metadata.posts;
        done();
    })

And should be inserted before the metalsmith-collections plugin in the pipeline. I'm not saying this is a smart hack, but it should get you going for the time being.

Considering this issue probably isn't the fault of this metalsmith-browser-sync plugin, we should probably move the conversation over to your repo if you want to continue.

@franklinjavier
Copy link
Author

Thanks for the solution.

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