Wednesday, 10 May 2017

connect-mongo document is not updated

Looking for help to find the possible reasons for a strange issue in my Express app (NodeJS V6, express-session with resave enabled, connect-mongo 1.3.2, mongodb 3.2 with native driver).

This happens only when I run my UI Tests using selenium with 50+ scenarios.

I have 3 route handlers, for instance step1, step2, and step3. In step1 I am setting the session data as:

request.session.myData = {
  id:"rnd1",
  message="initial value"
}

in step2 i am modifying this data as:

request.session.myData = {
  id:"rnd1",
  message="updated value"
}

in step3 I am trying to read the value in my session:

console.log(request.session.myData.id); 
console.log(request.session.myData.message);

and I get the following values:

rnd1
initial value

For some reason it behaves like the update I did in step2 is not persisted.

I already checked and ruled out the chances of step2 being skipped or a data being updated via reference from somewhere else.



via w3dev

No comments:

Post a Comment