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

implement fetchWithAbort and use it for partial page load, mappings & alphabetical index #1609

Merged
merged 5 commits into from
Mar 14, 2024

Conversation

osma
Copy link
Member

@osma osma commented Mar 13, 2024

Reasons for creating this PR

Trying to address the AJAX race conditions related to partial page load (#1561).

This PR defines a new JS function fetchWithAbort that wraps the fetch method but also keeps track of pending fetches (per category - there can be different categories) and aborts them early when it's called again.

Link to relevant issue(s), if any

Description of the changes in this PR

  • define function fetchWithAbort
  • use fetchWithAbort when performing partial page load and also when loading mappings for the concept page
  • use fetchWithAbort when loading entries for the alphabetical index

Known problems or uncertainties in this PR

  • The PR doesn't interact with the search field autocomplete widget, which is still WIP in PR Implement autocomplete for search #1589. I think the fetchWithAbort function would be useful there as well.
  • Should there be Cypress tests? How would they work?

Checklist

  • phpUnit tests pass locally with my changes
  • I have added tests that show that the new code works, or tests are not relevant for this PR (e.g. only HTML/CSS changes)
  • The PR doesn't reduce accessibility of the front-end code (e.g. tab focus, scaling to different resolutions, use of .sr-only class, color contrast)
  • The PR doesn't introduce unintended code changes (e.g. empty lines or useless reindentation)

@osma osma self-assigned this Mar 13, 2024
@osma osma added the bug label Mar 13, 2024
@osma osma added this to the 3.0 milestone Mar 13, 2024
@osma osma requested a review from UnniKohonen March 13, 2024 11:26
Copy link

codecov bot commented Mar 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.58%. Comparing base (f22c504) to head (fcf5be7).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #1609   +/-   ##
=========================================
  Coverage     70.58%   70.58%           
  Complexity     1647     1647           
=========================================
  Files            32       32           
  Lines          4321     4321           
=========================================
  Hits           3050     3050           
  Misses         1271     1271           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@osma osma changed the title implement fetchWithAbort and use it for partial page load & mappings implement fetchWithAbort and use it for partial page load, mappings & alphabetical index Mar 13, 2024
@osma osma marked this pull request as ready for review March 13, 2024 13:52
Copy link
Contributor

@UnniKohonen UnniKohonen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good to me and it seems to work correctly.

Cypress tests for partial page load on vocabulary home page fail sometimes because timeout isn't high enough. Not sure if the problem should be addressed in here, though, as it doesn't seem to originate from this PR.

@osma
Copy link
Member Author

osma commented Mar 14, 2024

You are right @UnniKohonen . I will increase the timeouts. I think it makes sense to do this on this PR branch rather than makkng a separate PR because the timeout problem is closely related even though it's probably not caused by new changes in this PR.

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@osma osma merged commit e853d49 into main Mar 14, 2024
11 of 12 checks passed
@osma osma deleted the issue1561-ajax-race-condition-fetch-with-abort branch March 14, 2024 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done (verified in test.dev.finto.fi, set Milestone 3.0 for both issue & PR)
Development

Successfully merging this pull request may close these issues.

Race conditions in Skosmos 3 AJAX requests
2 participants