Skip to content

Introduce automatic request cancellation#32268

Open
OmarHawk wants to merge 3 commits intojhipster:mainfrom
OmarHawk:feature/request-cancellation-angular-list-view
Open

Introduce automatic request cancellation#32268
OmarHawk wants to merge 3 commits intojhipster:mainfrom
OmarHawk:feature/request-cancellation-angular-list-view

Conversation

@OmarHawk
Copy link
Member

@OmarHawk OmarHawk commented Feb 9, 2026

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-ci label, you can still see CI build result at your branch.

@OmarHawk OmarHawk changed the title Introduce request automatic request cancellation Introduce automatic request cancellation Feb 9, 2026
@OmarHawk OmarHawk force-pushed the feature/request-cancellation-angular-list-view branch from 72a1b91 to 7e70b31 Compare February 9, 2026 15:08
@OmarHawk
Copy link
Member Author

OmarHawk commented Feb 9, 2026

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.

@OmarHawk OmarHawk force-pushed the feature/request-cancellation-angular-list-view branch from 80e0b94 to c453804 Compare February 9, 2026 16:00
@OmarHawk OmarHawk marked this pull request as ready for review February 9, 2026 16:02
@OmarHawk OmarHawk requested a review from qmonmert February 9, 2026 16:02
@OmarHawk OmarHawk marked this pull request as draft February 9, 2026 16:44
@OmarHawk OmarHawk marked this pull request as ready for review February 9, 2026 16:50
@OmarHawk OmarHawk self-assigned this Feb 10, 2026
@mshima mshima requested a review from Copilot February 13, 2026 14:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 use switchMap to ensure only the latest queryBackend() request remains active (non–infinite scroll only).
  • Route load() through loadTrigger$ 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.

@OmarHawk
Copy link
Member Author

I'll look into the proposals :)

@mshima
Copy link
Member

mshima commented Feb 13, 2026

Have you considered to use httpResource instead?

@OmarHawk
Copy link
Member Author

OmarHawk commented Feb 13, 2026

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?

@mshima
Copy link
Member

mshima commented Feb 13, 2026

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.
We will use only basic apis.
@qmonmert what do you think?

@OmarHawk OmarHawk marked this pull request as draft February 13, 2026 16:35
@OmarHawk
Copy link
Member Author

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.
Plus I'm not sure if that's the best "general" approach for our use cases (like also form handling). To me it looks best fitted for actual resource fetching (GET), but not for e.g. form submissions. At the moment, our service class has both - so I'm not sure, if this in the end makes things less complex tbh as we would probably require then both approaches...

Copy link
Member

@mshima mshima left a comment

Choose a reason for hiding this comment

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

I definitely think we should use httpResource in this case instead of the added complexity.

@OmarHawk OmarHawk force-pushed the feature/request-cancellation-angular-list-view branch from a1096d6 to 8082c62 Compare February 16, 2026 12:13
@OmarHawk OmarHawk marked this pull request as ready for review February 16, 2026 12:30
@OmarHawk
Copy link
Member Author

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.
@OmarHawk OmarHawk force-pushed the feature/request-cancellation-angular-list-view branch from 8082c62 to 5e589da Compare February 25, 2026 10:41
@OmarHawk
Copy link
Member Author

OmarHawk commented Feb 25, 2026

I'm just curious, if my tests pass, that's why I rebased. Would close the MR later as it is superseded by #32373

@OmarHawk OmarHawk force-pushed the feature/request-cancellation-angular-list-view branch from 0162def to 89072ac Compare February 25, 2026 10:44
});

// Reset the spy from beforeEach and set up delayed responses
<%= clientTestFramework %>.spyOn(service, 'query')
Copy link
Member

Choose a reason for hiding this comment

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

query is never called.

});

// Reset the spy from beforeEach and simulate error then success
<%= clientTestFramework %>.spyOn(service, 'query')
Copy link
Member

Choose a reason for hiding this comment

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

query is never called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants