Last active
December 31, 2015 15:49
-
-
Save huanglong-zz/8009232 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1. Session err for req.logIn | |
| a. Make sure you pass user to logIn: | |
| req.logIn(user, function(err) { | |
| if (err) return next(err) | |
| mail.sendActiveMail(user.email, user.token, user.username) | |
| return res.json({ | |
| success: 1 | |
| }) | |
| }) | |
| }) | |
| b. Make sure the right location for modules loading, especiall the passport.session | |
| cookieParser | |
| session | |
| passport.initialize | |
| passport.session | |
| app.router | |
| MATCH>> [ '(./node_modules/passport/lib/passport/http/request.js:30:30)', | |
| './node_modules/passport/lib/passport/http/request.js', | |
| '30', | |
| '30', | |
| index: 43, | |
| input: ' at IncomingMessage.req.login.req.logIn (./node_modules/passport/lib/passport/http/request.js:30:30)' ] | |
| MATCH>> [ '(./app/controllers/users.js:243:15)', | |
| './app/controllers/users.js', | |
| '243', | |
| '15', | |
| index: 27, | |
| input: ' at Promise.<anonymous> (./app/controllers/users.js:243:15)' ] | |
| MATCH>> [ '(./node_modules/mongoose/node_modules/mpromise/lib/promise.js:171:8)', | |
| './node_modules/mongoose/node_modules/mpromise/lib/promise.js', | |
| '171', | |
| '8', | |
| index: 27, | |
| input: ' at Promise.<anonymous> (./node_modules/mongoose/node_modules/mpromise/lib/promise.js:171:8)' ] | |
| MATCH>> [ '(events.js:98:17)', | |
| 'events.js', | |
| '98', | |
| '17', | |
| index: 33, | |
| input: ' at Promise.EventEmitter.emit (events.js:98:17)' ] | |
| Error: ENOENT, no such file or directory 'events.js' | |
| at Object.fs.openSync (fs.js:427:18) | |
| at Object.fs.readFileSync (fs.js:284:15) | |
| at injectSourceLines (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:107:23) | |
| at betterStack (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:155:10) | |
| at process.<anonymous> (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:208:36) | |
| at process.EventEmitter.emit (events.js:95:17) | |
| at process._fatalException (node.js:272:26) | |
| MATCH>> [ '(./node_modules/mongoose/node_modules/mpromise/lib/promise.js:88:38)', | |
| './node_modules/mongoose/node_modules/mpromise/lib/promise.js', | |
| '88', | |
| '38', | |
| index: 20, | |
| input: ' at Promise.emit (./node_modules/mongoose/node_modules/mpromise/lib/promise.js:88:38)' ] | |
| MATCH>> [ '(./node_modules/mongoose/node_modules/mpromise/lib/promise.js:101:20)', | |
| './node_modules/mongoose/node_modules/mpromise/lib/promise.js', | |
| '101', | |
| '20', | |
| index: 23, | |
| input: ' at Promise.fulfill (./node_modules/mongoose/node_modules/mpromise/lib/promise.js:101:20)' ] | |
| MATCH>> [ '(./node_modules/mongoose/lib/model.js:133:13)', | |
| './node_modules/mongoose/lib/model.js', | |
| '133', | |
| '13', | |
| index: 18, | |
| input: ' at handleSave (./node_modules/mongoose/lib/model.js:133:13)' ] | |
| MATCH>> [ 'at ./node_modules/mongoose/lib/utils.js:408:16', | |
| './node_modules/mongoose/lib/utils.js', | |
| '408', | |
| '16', | |
| index: 4, | |
| input: ' at ./node_modules/mongoose/lib/utils.js:408:16' ] | |
| MATCH>> [ 'at ./node_modules/mongoose/node_modules/mongodb/lib/mongodb/collection.js:347:9', | |
| './node_modules/mongoose/node_modules/mongodb/lib/mongodb/collection.js', | |
| '347', | |
| '9', | |
| index: 4, | |
| input: ' at ./node_modules/mongoose/node_modules/mongodb/lib/mongodb/collection.js:347:9' ] | |
| MATCH>> [ '(./node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/base.js:382:41)', | |
| './node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/base.js', | |
| '382', | |
| '41', | |
| index: 32, | |
| input: ' at Server.Base._callHandler (./node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/base.js:382:41)' ] | |
| MATCH>> [ 'at ./node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:472:18', | |
| './node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js', | |
| '472', | |
| '18', | |
| index: 4, | |
| input: ' at ./node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:472:18' ] | |
| MATCH>> [ '(./node_modules/mongoose/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)', | |
| './node_modules/mongoose/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js', | |
| '68', | |
| '5', | |
| index: 28, | |
| input: ' at MongoReply.parseBody (./node_modules/mongoose/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)' ] | |
| MATCH>> [ '(./node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:430:20)', | |
| './node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js', | |
| '430', | |
| '20', | |
| index: 24, | |
| input: ' at null.<anonymous> (./node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:430:20)' ] | |
| MATCH>> [ '(events.js:95:17)', | |
| 'events.js', | |
| '95', | |
| '17', | |
| index: 25, | |
| input: ' at EventEmitter.emit (events.js:95:17)' ] | |
| Error: ENOENT, no such file or directory 'events.js' | |
| at Object.fs.openSync (fs.js:427:18) | |
| at Object.fs.readFileSync (fs.js:284:15) | |
| at injectSourceLines (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:107:23) | |
| at betterStack (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:155:10) | |
| at process.<anonymous> (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:208:36) | |
| at process.EventEmitter.emit (events.js:95:17) | |
| at process._fatalException (node.js:272:26) | |
| MATCH>> [ '(./node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:191:13)', | |
| './node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js', | |
| '191', | |
| '13', | |
| index: 24, | |
| input: ' at null.<anonymous> (./node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:191:13)' ] | |
| MATCH>> [ '(events.js:98:17)', | |
| 'events.js', | |
| '98', | |
| '17', | |
| index: 25, | |
| input: ' at EventEmitter.emit (events.js:98:17)' ] | |
| Error: ENOENT, no such file or directory 'events.js' | |
| at Object.fs.openSync (fs.js:427:18) | |
| at Object.fs.readFileSync (fs.js:284:15) | |
| at injectSourceLines (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:107:23) | |
| at betterStack (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:155:10) | |
| at process.<anonymous> (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:208:36) | |
| at process.EventEmitter.emit (events.js:95:17) | |
| at process._fatalException (node.js:272:26) | |
| MATCH>> [ '(./node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:384:22)', | |
| './node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js', | |
| '384', | |
| '22', | |
| index: 26, | |
| input: ' at Socket.<anonymous> (./node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:384:22)' ] | |
| MATCH>> [ '(events.js:95:17)', | |
| 'events.js', | |
| '95', | |
| '17', | |
| index: 32, | |
| input: ' at Socket.EventEmitter.emit (events.js:95:17)' ] | |
| Error: ENOENT, no such file or directory 'events.js' | |
| at Object.fs.openSync (fs.js:427:18) | |
| at Object.fs.readFileSync (fs.js:284:15) | |
| at injectSourceLines (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:107:23) | |
| at betterStack (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:155:10) | |
| at process.<anonymous> (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:208:36) | |
| at process.EventEmitter.emit (events.js:95:17) | |
| at process._fatalException (node.js:272:26) | |
| MATCH>> [ '(_stream_readable.js:746:14)', | |
| '_stream_readable.js', | |
| '746', | |
| '14', | |
| index: 26, | |
| input: ' at Socket.<anonymous> (_stream_readable.js:746:14)' ] | |
| Error: ENOENT, no such file or directory '_stream_readable.js' | |
| at Object.fs.openSync (fs.js:427:18) | |
| at Object.fs.readFileSync (fs.js:284:15) | |
| at injectSourceLines (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:107:23) | |
| at betterStack (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:155:10) | |
| at process.<anonymous> (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:208:36) | |
| at process.EventEmitter.emit (events.js:95:17) | |
| at process._fatalException (node.js:272:26) | |
| MATCH>> [ '(events.js:92:17)', | |
| 'events.js', | |
| '92', | |
| '17', | |
| index: 32, | |
| input: ' at Socket.EventEmitter.emit (events.js:92:17)' ] | |
| Error: ENOENT, no such file or directory 'events.js' | |
| at Object.fs.openSync (fs.js:427:18) | |
| at Object.fs.readFileSync (fs.js:284:15) | |
| at injectSourceLines (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:107:23) | |
| at betterStack (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:155:10) | |
| at process.<anonymous> (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:208:36) | |
| at process.EventEmitter.emit (events.js:95:17) | |
| at process._fatalException (node.js:272:26) | |
| MATCH>> [ '(_stream_readable.js:408:10)', | |
| '_stream_readable.js', | |
| '408', | |
| '10', | |
| index: 21, | |
| input: ' at emitReadable_ (_stream_readable.js:408:10)' ] | |
| Error: ENOENT, no such file or directory '_stream_readable.js' | |
| at Object.fs.openSync (fs.js:427:18) | |
| at Object.fs.readFileSync (fs.js:284:15) | |
| at injectSourceLines (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:107:23) | |
| at betterStack (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:155:10) | |
| at process.<anonymous> (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:208:36) | |
| at process.EventEmitter.emit (events.js:95:17) | |
| at process._fatalException (node.js:272:26) | |
| MATCH>> [ '(_stream_readable.js:404:5)', | |
| '_stream_readable.js', | |
| '404', | |
| '5', | |
| index: 20, | |
| input: ' at emitReadable (_stream_readable.js:404:5)' ] | |
| Error: ENOENT, no such file or directory '_stream_readable.js' | |
| at Object.fs.openSync (fs.js:427:18) | |
| at Object.fs.readFileSync (fs.js:284:15) | |
| at injectSourceLines (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:107:23) | |
| at betterStack (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:155:10) | |
| at process.<anonymous> (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:208:36) | |
| at process.EventEmitter.emit (events.js:95:17) | |
| at process._fatalException (node.js:272:26) | |
| MATCH>> [ '(_stream_readable.js:165:9)', | |
| '_stream_readable.js', | |
| '165', | |
| '9', | |
| index: 24, | |
| input: ' at readableAddChunk (_stream_readable.js:165:9)' ] | |
| Error: ENOENT, no such file or directory '_stream_readable.js' | |
| at Object.fs.openSync (fs.js:427:18) | |
| at Object.fs.readFileSync (fs.js:284:15) | |
| at injectSourceLines (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:107:23) | |
| at betterStack (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:155:10) | |
| at process.<anonymous> (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:208:36) | |
| at process.EventEmitter.emit (events.js:95:17) | |
| at process._fatalException (node.js:272:26) | |
| MATCH>> [ '(_stream_readable.js:127:10)', | |
| '_stream_readable.js', | |
| '127', | |
| '10', | |
| index: 28, | |
| input: ' at Socket.Readable.push (_stream_readable.js:127:10)' ] | |
| Error: ENOENT, no such file or directory '_stream_readable.js' | |
| at Object.fs.openSync (fs.js:427:18) | |
| at Object.fs.readFileSync (fs.js:284:15) | |
| at injectSourceLines (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:107:23) | |
| at betterStack (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:155:10) | |
| at process.<anonymous> (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:208:36) | |
| at process.EventEmitter.emit (events.js:95:17) | |
| at process._fatalException (node.js:272:26) | |
| MATCH>> [ '(net.js:526:21)', | |
| 'net.js', | |
| '526', | |
| '21', | |
| index: 18, | |
| input: ' at TCP.onread (net.js:526:21)' ] | |
| Error: ENOENT, no such file or directory 'net.js' | |
| at Object.fs.openSync (fs.js:427:18) | |
| at Object.fs.readFileSync (fs.js:284:15) | |
| at injectSourceLines (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:107:23) | |
| at betterStack (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:155:10) | |
| at process.<anonymous> (/Users/black/Projects/beta/node_modules/express-error/lib/expressError.js:208:36) | |
| at process.EventEmitter.emit (events.js:95:17) | |
| at process._fatalException (node.js:272:26) | |
| Uncaught exception passport.initialize() middleware not in use | |
| at IncomingMessage.req.login.req.logIn (./node_modules/passport/lib/passport/http/request.js:30:30) | |
| 27: */ | |
| 28: req.login = | |
| 29: req.logIn = function(user, options, done) { | |
| 30: if (!this._passport) throw new Error('passport.initialize() middleware not in use'); | |
| 31: | |
| 32: if (!done && typeof options === 'function') { | |
| 33: done = options; | |
| at Promise.<anonymous> (./app/controllers/users.js:243:15) | |
| 240: }] | |
| 241: }) | |
| 242: } | |
| 243: req.logIn(user, function(err) { | |
| 244: if (err) return next(err) | |
| 245: req.session.user = user | |
| 246: req.session.role = user.role | |
| at Promise.<anonymous> (./node_modules/mongoose/node_modules/mpromise/lib/promise.js:171:8) | |
| 168: | |
| 169: this.on(this.constructor.SUCCESS, function(){ | |
| 170: var args = slice(arguments); | |
| 171: fn.apply(this, [null].concat(args)); | |
| 172: }); | |
| 173: | |
| 174: return this; | |
| at Promise.EventEmitter.emit (events.js:98:17) | |
| at Promise.emit (./node_modules/mongoose/node_modules/mpromise/lib/promise.js:88:38) | |
| 85: this.emitted[event] = slice(arguments, 1); | |
| 86: } | |
| 87: | |
| 88: return EventEmitter.prototype.emit.apply(this, arguments); | |
| 89: } | |
| 90: | |
| 91: /** | |
| at Promise.fulfill (./node_modules/mongoose/node_modules/mpromise/lib/promise.js:101:20) | |
| 98: | |
| 99: Promise.prototype.fulfill = function () { | |
| 100: var args = slice(arguments); | |
| 101: return this.emit.apply(this, [this.constructor.SUCCESS].concat(args)); | |
| 102: } | |
| 103: | |
| 104: /** | |
| at handleSave (./node_modules/mongoose/lib/model.js:133:13) | |
| 130: } | |
| 131: | |
| 132: self.emit('save', self, numAffected); | |
| 133: promise.complete(self, numAffected); | |
| 134: promise = self = null; | |
| 135: }); | |
| 136: } | |
| at ./node_modules/mongoose/lib/utils.js:408:16 | |
| 405: if ('function' !== typeof callback) return; | |
| 406: return function () { | |
| 407: try { | |
| 408: callback.apply(this, arguments); | |
| 409: } catch (err) { | |
| 410: // only nextTick on err to get out of | |
| 411: // the event loop and avoid state corruption. | |
| at ./node_modules/mongoose/node_modules/mongodb/lib/mongodb/collection.js:347:9 | |
| 344: } else if(error[0].err || error[0].errmsg) { | |
| 345: callback(utils.toError(error[0])); | |
| 346: } else { | |
| 347: callback(null, docs); | |
| 348: } | |
| 349: }); | |
| 350: } else if(_hasWriteConcern(errorOptions) && callback == null) { | |
| at Server.Base._callHandler (./node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/base.js:382:41) | |
| 379: | |
| 380: try { | |
| 381: // Execute the callback if one was provided | |
| 382: if(typeof callback == 'function') callback(err, document, info.connection); | |
| 383: } catch(err) { | |
| 384: self._emitAcrossAllDbInstances(self, null, "error", err, self, true, true); | |
| 385: } | |
| at ./node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:472:18 | |
| 469: } | |
| 470: | |
| 471: // Dispatch the call | |
| 472: server._callHandler(mongoReply.responseTo, mongoReply, null); | |
| 473: | |
| 474: // If we have an error about the server not being master or primary | |
| 475: if((mongoReply.responseFlag & (1 << 1)) != 0 | |
| at MongoReply.parseBody (./node_modules/mongoose/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5) | |
| 65: } | |
| 66: | |
| 67: // No error return | |
| 68: callback(null); | |
| 69: } catch(err) { | |
| 70: return callback(err); | |
| 71: } | |
| at null.<anonymous> (./node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:430:20) | |
| 427: server._reRegisterHandler(mongoReply.requestId, callbackInfo); | |
| 428: } | |
| 429: // Parse the body | |
| 430: mongoReply.parseBody(message, connectionPool.bson, callbackInfo.info.raw, function(err) { | |
| 431: if(err != null) { | |
| 432: // If pool connection is already closed | |
| 433: if(server._serverState === 'disconnected') return; | |
| at EventEmitter.emit (events.js:95:17) | |
| at null.<anonymous> (./node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:191:13) | |
| 188: }); | |
| 189: | |
| 190: connection.on("message", function(message) { | |
| 191: _self.emit("message", message); | |
| 192: }); | |
| 193: | |
| 194: // Start connection in the next tick | |
| at EventEmitter.emit (events.js:98:17) | |
| at Socket.<anonymous> (./node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:384:22) | |
| 381: // Exit parsing loop | |
| 382: data = new Buffer(0); | |
| 383: // Emit the message | |
| 384: self.emit("message", emitBuffer, self); | |
| 385: } catch (err) { | |
| 386: var errorObject = {err:"socketHandler", trace:err, bin:self.buffer, parseState:{ | |
| 387: sizeOfMessage:self.sizeOfMessage, | |
| at Socket.EventEmitter.emit (events.js:95:17) | |
| at Socket.<anonymous> (_stream_readable.js:746:14) | |
| at Socket.EventEmitter.emit (events.js:92:17) | |
| at emitReadable_ (_stream_readable.js:408:10) | |
| at emitReadable (_stream_readable.js:404:5) | |
| at readableAddChunk (_stream_readable.js:165:9) | |
| at Socket.Readable.push (_stream_readable.js:127:10) | |
| at TCP.onread (net.js:526:21) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment