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

Error: Callback was already called #28

Closed
DundieWinner opened this issue Mar 24, 2017 · 1 comment
Closed

Error: Callback was already called #28

DundieWinner opened this issue Mar 24, 2017 · 1 comment

Comments

@DundieWinner
Copy link

I am working through Chapter 8, page 177 where I am trying to get the photo album server to startup after implementing the very first steps in MongoDB integration, and I keep getting the same error sequence:

..\Node\Tutorial\photo_album_express\app\node_modules\mongodb\lib\mongo_client.js:350
throw err
^
Error: Callback was already called.
at ..\Node\Tutorial\photo_album_express\app\node_modules\async\dist\async.js:840:32
at Db.collection (..\Node\Tutorial\photo_album_express\app\node_modules\mongodb\lib\db.js:457:27)
at async.waterfall.exports.albums (..\Node\Tutorial\photo_album_express\app\data\db.js:33:16)
at nextTask (..\Node\Tutorial\photo_album_express\app\node_modules\async\dist\async.js:5070:14)
at ..\Node\Tutorial\photo_album_express\app\node_modules\async\dist\async.js:5064:13
at apply (..\Node\Tutorial\photo_album_express\app\node_modules\async\dist\async.js:21:25)
at ..\Node\Tutorial\photo_album_express\app\node_modules\async\dist\async.js:56:12
at ..\Node\Tutorial\photo_album_express\app\node_modules\async\dist\async.js:843:16
at MongoClient.connect (..\Node\Tutorial\photo_album_express\app\data\db.js:25:17)
at connectCallback (..\Node\Tutorial\photo_album_express\app\node_modules\mongodb\lib\mongo_client.js:428:5)

The "db.js:33:16" is referencing the db.collection("albums", cb); line and the "db.js:25:17" is referencing the cb(null) line within the MongoClient.connect function.

I even tried replacing my data/db.js file with exactly what you provide in repository (https://github.com/marcwan/LearningNodeJS/blob/master/Chapter08/02_create_album/app/data/db.js)

I've searched around but I can't seem to figure out this snag. What is happening?

@DundieWinner
Copy link
Author

The problem is collection() function. Replacing it with createCollection() solves this issue for me. See my pull request: #29

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

1 participant