SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: page 15

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    page 15

    got to page 15, and added , User = require('./models/User.js'); but when i try to start the app im getting the following error. any ideas on what i might be doing wrong?

    Code javascript:
    /authentication/node_modules/mongoose/lib/utils.js:413
            throw err;
                  ^
    Error: Uncaught, unspecified 'error' event.
        at NativeConnection.EventEmitter.emit (events.js:73:15)
        at Model.init (/authentication/node_modules/mongoose/lib/model.js:554:31)
        at exports.tick (/authentication/node_modules/mongoose/lib/utils.js:408:16)
        at Db.ensureIndex (/authentication/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1066:28)
        at Db.indexInformation (/authentication/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1200:28)
        at Cursor.toArray (/authentication/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:124:30)
        at Cursor.each (/authentication/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:166:32)
        at Cursor.nextObject.self.queryRun (/authentication/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:441:39)
        at Cursor.close (/authentication/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:687:5)
        at Cursor.nextObject.commandHandler (/authentication/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:441:21)

    1. if i comment out in /authentication/models/User.js, the line var MyUser = db.mongoose.model('User', UserSchema); then the app starts without throwing an error.
    2. when i change /authentication/node_modules/mongoose/node_modules/mongodb/lib/mongodb/utils.js line 413 to console.log(err) i get : [Error: Uncaught, unspecified 'error' event.]
    3. when i change /authentication/node_modules/mongoose/node_modules/mongodb/lib/mongodb/utils.js line 413 to console.log(callback) i get : [function]
    4. when i add to /authentication/node_modules/mongoose/node_modules/mongodb/lib/mongodb/model.js 554, console.log(err); i get an error which i believe is the problem - unauthorized db:nodemarket ns:nodemarket.system.indexes lock type:0 client: xxx.xxx.xxx.xxx (my ip address)
      1. how do i fix that?
      2. why doesnt node show this error instead of Uncaught, unspecified 'error' event?

  2. #2
    SitePoint Addict
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so this turned out to be a credential issue. once i corrected the password, the code worked.

    now i wonder, why does node not provide a clearer exception?

    it appears that mongolab does provide something that is a bit clearer as noted above, but even so, an error stating that the credentials given are not valid would have been much more helpful than :
    Code javascript:
    Error: Uncaught, unspecified 'error' event.

  3. #3
    SitePoint Addict
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    don, any thoughts, comments, etc ... ?

  4. #4
    SitePoint Author
    Join Date
    Nov 2012
    Posts
    48
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Node.js doesn't really 'know' about credentials errors. A more comprehensive exception handling mechanism would have provided a more user friendly message. However due to space constraints, exception handling was deliberately kept bare bones.

  5. #5
    SitePoint Addict
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks. i realize that node doesn’t know about credential errors; it’s just that the mongoose module does and contains an exception error that makes more sense, but for whatever reason it’s not passed up the exception chain, which would have been more helpful. guess i can take a look at it later if i get a chance and see if i can pass it up the chain and submit a pull request ...

  6. #6
    SitePoint Member
    Join Date
    Feb 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by danNL View Post
    thanks. i realize that node doesnt know about credential errors; its just that the mongoose module does and contains an exception error that makes more sense, but for whatever reason its not passed up the exception chain, which would have been more helpful. guess i can take a look at it later if i get a chance and see if i can pass it up the chain and submit a pull request ...
    Hi dan, could you or Don possibly elaborate on how to fix this problem? I just arrived at the same place in the book and I'm stuck with the same problem. Thanks

  7. #7
    SitePoint Member
    Join Date
    Feb 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, so I was using my credentials for my Mongolab ACCOUNT and not the MongoDB 'nockmarket' database itself. A little bit of a confusion there. Credentials have been fixed. Thanks.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •