alphagov / govuk-prototype-kit

Rapidly create HTML prototypes of GOV.UK services
https://prototype-kit.service.gov.uk
MIT License
303 stars 236 forks source link

Data stops getting stored to session #2393

Closed joelanman closed 6 months ago

joelanman commented 6 months ago

Description of the issue

We're getting a few reports that data stops getting stored to session sometimes. Clearing .tmp/sessions seems to fix Other reports suggest this happens in Chrome and not other browsers

Steps to reproduce the issue

Actual vs expected behaviour

Environment (where applicable)

enoranidi commented 6 months ago

I have added a video to show what is happening for me at the moment when I use the latest version of Chrome and the GOV.UK Prototype Kit: https://www.loom.com/share/7ac82f624a3141aba433d9d309bd352d?sid=e8c845f2-0a70-400e-92f3-f93401d7d81d

enoranidi commented 6 months ago

Operating system: macOS Sonoma Browser: Chrome Browser version: 121.0.6167.184 (Official Build) (arm64) GOV.UK Prototype Kit version: v13.16.0

StuBamforthDWP commented 6 months ago

Loom video showing my issue with data not being passes through pages. The applicant name and organisation name are inserted into subsequent questions to add context, the applicant name isn't being passed through. Also the details captured in the questions are not being displayed on the Check your answers page.

https://www.loom.com/share/6b33464f6bc346c38b9dfea4835e7779?sid=bf532f85-42e8-41ec-a259-2477d4352b08

StuBamforthDWP commented 6 months ago

Operating system: macOS Catalina 10.15.7 Browser: Chrome Browser version: 121.0.6167.184 (Official Build) (x86_64) GOV.UK Prototype Kit version: v13.16.0

StuBamforthDWP commented 6 months ago

Clearing .tmp/sessions via the Terminal fixed the issue for me.

Entered:

rm -rf .tmp/sessions

in the VS Code terminal.

Then restarted the app and it's working again.

HarryMtds commented 6 months ago

I am having the same issue that everyone else is. It affects prototypes running locally and in Heroku.

I've not been able to reproduce the error reliably. It happens randomly when moving from one page, through a route to another page. It forgets everything stored in session and the session object is no longer able to be read from or written too.

Given that clearing all the JSON files in .tmp/sessions fixes the issue- I think that something in there is the cause of the issue. I would go through these and check but given that a new JSON session file is created on every page load, this would take a prohibitive amount of time.

Operating system: MacOS 14.3.1 (23D60) Browser: Chrome Browser version: 121.0.6167.184 GOV.UK Prototype Kit version: 13.16.0 Node version: 20.10.0

joelanman commented 6 months ago

@HarryMtds thanks, does it happen in other browsers?

HarryMtds commented 6 months ago

Can't seem to replicate it in Safari. I have noticed an interesting difference in behaviour between Chrome and Safari.

Chrome:

  1. Delete all files in .tmp/sessions
  2. Open localhost:3000
  3. Two JSON files are created in .tmp/sessions The difference between these files is the cookies.expires value

Safari:

  1. Delete all files in .tmp/sessions
  2. Open localhost:3000
  3. One JSON file created in .tmp/sessions

Edit:

On further inspection, chrome generates a new session file on every page load, whereas Safari does not

joelanman commented 6 months ago

@HarryMtds super helpful thanks!

36degrees commented 6 months ago

I've been trying to get to the bottom of what's going on here… a few observations so far…

joelanman commented 6 months ago

the timing of the issue seems to point to the manifest being a possible cause - we could try asking people who see this issue to try something like this in their app/views/layouts/main.html:

{% block headIcons %}{% endblock %}