Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race condition occurs when logging in as offline user with slow connection #7242

Closed
newtewt opened this issue Aug 9, 2021 · 3 comments
Closed
Assignees
Labels
Type: Bug Fix something that isn't working as intended
Milestone

Comments

@newtewt
Copy link
Contributor

newtewt commented Aug 9, 2021

Describe the issue
When running a test for an offline user the service worker gets installed and registers. There is a race condition where onupdatefound is not triggered. This causes the app to log in and then sit on the "Downloading App..." screen.

This can be recreated by checking out this branch and running npm run wdio-local on your local machine.

This can be recreated in chrome using a local docker setup.

I setup my instance using the scripts/docker-helper/cht-docker-compose.sh
Created an offline user.
Cleared cache and unregistered all service workers.
Opened a new blank tab. Set my network throttling to slow 3g
Navigate to my local instance https://192-168-1-215.my.local-ip.co/
Quickly log in as the offline user as soon as the login fields show.
The app sits on Downloading App... page

Describe the improvement you'd like
Resolve the race condition or potentially find another event to wait on in the test.

Describe alternatives you've considered
@dianabarsan has put together a change that possibly fixes this issue but needs to be vetted more thoroughly.

@newtewt newtewt added the Type: Technical issue Improve something that users won't notice label Aug 9, 2021
@dianabarsan dianabarsan self-assigned this Aug 9, 2021
@newtewt newtewt changed the title Race condition occurs when logging in as offline user with webdriverIO Race condition occurs when logging in as offline user with slow connection Sep 9, 2021
@dianabarsan dianabarsan added this to Ready for dev in Care Teams Workstream via automation Sep 18, 2021
@dianabarsan dianabarsan added this to the 3.14.0 milestone Sep 18, 2021
@dianabarsan dianabarsan moved this from Ready for dev to Dev in progress in Care Teams Workstream Sep 18, 2021
@dianabarsan dianabarsan added Type: Bug Fix something that isn't working as intended and removed Type: Technical issue Improve something that users won't notice labels Sep 22, 2021
@dianabarsan
Copy link
Member

This is ready for AT on 6338-live-service-worker

  • offline users should be able to login in wdio
  • all users should be able to login on slow networks
  • all users should be able to login on fast networks

@dianabarsan dianabarsan moved this from Dev in progress to Ready for AT in Care Teams Workstream Sep 29, 2021
@ngaruko ngaruko moved this from Ready for AT to AT in progress in Care Teams Workstream Oct 4, 2021
@ngaruko
Copy link
Contributor

ngaruko commented Oct 4, 2021

Tested on local. LGTM @dianabarsan

  1. able to login on fast networks

  2. wdio test that requires offline login passes this time
    image

  3. login with 3G slow network
    image

@ngaruko ngaruko moved this from AT in progress to Ready to merge in Care Teams Workstream Oct 4, 2021
dianabarsan added a commit that referenced this issue Oct 10, 2021
Removes service-worker grunt task.
Ddoc extraction no longer bumps the service-worker-meta doc.

Service worker is now generated in API:
- once on startup, after migrations
- every time the main ddoc is updated
- every time translations are changed (or added or removed)
- every time the branding doc is changed
If the call to sw-precache fails, the process crashes. Other errors are caught.
Config that we pass to sw-precache is unchanged, excepting:
- ignoreUrlParametersMatching now also includes username to fix the login page cache.
- dynamicUrlToDependencies for the login page receives the generated html of login page (that includes branding and translations), to make sure cache is busted at the correct times. As a consequence, the login controller now exports a renderLogin method that returns the generated login page.
After the service-worker file is generated (and saved in the same location as before), the service worker meta doc is updated. Updating the meta doc is skipped if no changes are made to the service-worker script (if the sha1 hash of the former file matches the sha1 hash of the new file).

Migrates service-worker e2e test to wdio.
Fixes race condition in bootstrap service-woker installation code, where registration promises only resolved when the service worker was already installed. On slow connections, where installation had not yet succeeded on the login page, the page would be left hanging.

#6338
#7307
#7242
@dianabarsan
Copy link
Member

Merged to master.

Care Teams Workstream automation moved this from Ready to merge to Done Oct 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Fix something that isn't working as intended
Projects
No open projects
Development

No branches or pull requests

3 participants