Introduce automatic request cancellation#32268
Introduce automatic request cancellation#32268OmarHawk wants to merge 3 commits intojhipster:mainfrom
Conversation
72a1b91 to
7e70b31
Compare
|
Ah, infinite scroll won't work easily with this approach. I'll check what I can do. Maybe just having this supported for standard pagination. |
80e0b94 to
c453804
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the generated Angular entity list component template to prevent stale HTTP responses from overwriting newer list results by canceling prior in-flight requests (except when infinite scroll is enabled).
Changes:
- Add a
loadTrigger$Subject and useswitchMapto ensure only the latestqueryBackend()request remains active (non–infinite scroll only). - Route
load()throughloadTrigger$for non–infinite scroll, keeping existing direct-load behavior for infinite scroll. - Update RxJS imports accordingly.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...ators/angular/templates/src/main/webapp/app/entities/_entityFolder_/list/_entityFile_.ts.ejs
Outdated
Show resolved
Hide resolved
...ators/angular/templates/src/main/webapp/app/entities/_entityFolder_/list/_entityFile_.ts.ejs
Outdated
Show resolved
Hide resolved
...ators/angular/templates/src/main/webapp/app/entities/_entityFolder_/list/_entityFile_.ts.ejs
Outdated
Show resolved
Hide resolved
|
I'll look into the proposals :) |
|
Have you considered to use httpResource instead? |
Actually no. In https://angular.dev/api/common/http/httpResource it says it is still experimental, so wdyt? |
I prefer to introduce httpResource instead of the added complexity. |
|
I've looked a bit more into httpResource and it looks like it would require changes in various places (i.e. a lot of work ;-)) if we want to consistently use it everywhere. |
mshima
left a comment
There was a problem hiding this comment.
I definitely think we should use httpResource in this case instead of the added complexity.
a1096d6 to
8082c62
Compare
|
I've finished the Pull Request anyway and added the remarked missing tests and error handling, just to maybe have an option in case we go for a "bugfix first" and move the imo bigger / possibly structural changes to "later". (I guess, I'm missing time to add httpResource support/corresponding changes myself!) |
in Angular list views, except for when having infiniteScroll enabled. Also add Destroy handling to clean up after moving away from component.
8082c62 to
5e589da
Compare
|
I'm just curious, if my tests pass, that's why I rebased. Would close the MR later as it is superseded by #32373 |
0162def to
89072ac
Compare
| }); | ||
|
|
||
| // Reset the spy from beforeEach and set up delayed responses | ||
| <%= clientTestFramework %>.spyOn(service, 'query') |
| }); | ||
|
|
||
| // Reset the spy from beforeEach and simulate error then success | ||
| <%= clientTestFramework %>.spyOn(service, 'query') |
in Angular list views, unless having infinite scroll enabled
We have noticed, that requests in list views do not get automatically canceled when the user may trigger a new request by quickly changing things like search string or removing the search string again.
The request that finishes later (can be the one started at first) will always override the resulting list. So: If you have a long running search operation (like 3-4s) and then basically remove the search parameters, a new request will be triggered for the unfiltered view again. That one most often finishes much faster than a search on a large dataset, but since the search is not canceled, it will also finish and show search results, even though the user had already removed the search... Can lead to inconsistent views of the results.
Please make sure the below checklist is followed for Pull Requests.
When you are still working on the PR, consider converting it to Draft (below reviewers) and adding
skip-cilabel, you can still see CI build result at your branch.