question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property 'expires' of undefined when using the crypto option

See original GitHub issue

This error only appears when crypto.secret is set.

I have done some debugging and the issue seems to be that the session object is over stringified while the crypto option is used. Therefore, the session json is not converted to an object while the createSession function treats the session parameter as an object.

At MongoStore.js line 197, the session is still a json string when it is passed to callback.:

const s = session && this.transformFunctions.unserialize(session.session);
if (this.options.touchAfter > 0 && (session === null || session === void 0 ? void 0 : session.lastModified)) {
    s.lastModified = session.lastModified;
}
this.emit('get', sid);
callback(null, s);

Trace:

TypeError: Cannot read property 'expires' of undefined
    at MongoStore.Store.createSession (...\node_modules\express-session\session\store.js:87:29)
    at inflate (...\node_modules\express-session\index.js:368:13)
    at ...\node_modules\express-session\index.js:495:11
    at ...\node_modules\connect-mongo\build\main\lib\MongoStore.js:202:17

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mingchunocommented, Mar 2, 2021

fixed in 4.2.2

1reaction
jas-commented, Feb 28, 2021

As an FYI, a new release for kruptein should address this with v3.0.0. I have been testing with the example project and should have a PR soon

Read more comments on GitHub >

github_iconTop Results From Across the Web

Express.io "Cannot read property of 'expires' of undefined"
This is my first time working with node.js and I am trying to use express.io to save cookies. I have literally carbon copied...
Read more >
Existing encrypted v3.2.0 sessions are not decrypted correctly ...
Behaviour in 3.2.0 is not expected as stated in TypeError: Cannot read property 'expires' of undefined when using the crypto option #393 so ......
Read more >
San Diego Patch 7 - Product Documentation | ServiceNow
Reconciliation for Oracle publisher failed due to the following error: 'TypeError: Cannot read property 'max_size_on_cloud' from undefined' ...
Read more >
cannot read properties of undefined (reading 'auth') firebase
onAuthStateChanged ( (user)" 2 i am new to using react native and firebase, I have this error: "TypeError: Cannot read property 'auth' of...
Read more >
Cannot read property 'remove' of undefined in customer-data.js
Here's how to easily fix it in Magento 2.4.3-p1. Uncaught TypeError: Cannot read property 'remove' of undefined at customer-data.js:178 at ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found