TypeError: cb is not a function
See original GitHub issueI’ve encountered this error. When logging out from the web application it throws a TypeError
.
My code that is in use:
var mongoose = require('mongoose')
mongoose.Promise = global.Promise
var session = require('express-session')
var MongoStore = require('connect-mongo')(session)
app.use(session({
secret: "verySecretKey",
resave: true,
saveUninitialized: true,
cookie: { maxAge: 19 * 60000 }, // store for 19 minutes
store: new MongoStore({
mongooseConnection: mongoose.connection
})
}))
process.on('unhandledRejection', (reason, p) => {
console.log('app.js - Unhandled Rejection at: \nPromise', p, '\nreason:', reason);
});
The code which runs when logging out:
router.get(['/login','/logout'], function(req, res){
req.session.destroy()
res.redirect("/")
})
Console output after logout:
app.js - Unhandled Rejection at:
Promise Promise {
<rejected> TypeError: cb is not a function
at promise.then.res (/home/efkan/Projects/awesome/node_modules/connect-mongo/src/index.js:7:18)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7) }
reason: TypeError: cb is not a function
at promise.then.res (/home/efkan/Projects/awesome/node_modules/connect-mongo/src/index.js:7:18)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
The error specifies this line of connect-mongo
source code
Development environment:
Module Name | Version |
---|---|
connect-mongo | 2.0.0 |
mongoose | 4.12.4 |
express-session | 1.9.3 |
express | 4.10.6 |
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:9 (3 by maintainers)
Top Results From Across the Web
TypeError: cb is not a function - javascript - Stack Overflow
1. You aren't passing any cb s to any of the three functions that require a callback as a second parameter. – CertainPerformance...
Read more >TypeError: cb is not a function #917 - tediousjs/tedious - GitHub
Hi @Steexyz, for the 'cb' function issue, there is a change under PR #845 that has been recently merged into master which introduce...
Read more >How I fixed a "cb.apply is not a function" error ... - Flavio Copes
I regularly use Gitbook, a little Node.js software used to generate an ebook from a set of markdown files. I use it for...
Read more >Android : TypeError: cb.apply is not a function - YouTube
https://www.hows.tech/p/recommended.html ] Android : TypeError : cb.apply is not a function Note: The information provided in this video is as it ...
Read more >npm ERR! cb.apply is not a function SOLVED - YouTube
How to solve npm ERR! cb.apply is not a function is shown. ... npm ERR! cb.apply is not a function SOLVED | node...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You have to pass a callback in your
destroy
call.req.session.destroy(cb)
Fixed in version 2.0.1. Thx @brainthinks!!