79387654

Date: 2025-01-25 22:47:19
Score: 2.5
Natty:
Report link

For people who have the same issue:

It was fixed by using the ngOnDestroy event of Angular. You need to unsubscribe from these requests because they are not canceled otherwise:

Example:

export class MyComponent implements OnDestroy {
   private subscriptions: Subscription[] = []
   
   ngOnDestroy(): void {
    this.subscriptions.forEach(s => s.unsubscribe());
  }

  myApiFunction(feature_id: number, vote: boolean): void {
    const feature_vote: Subscription = this.apiService.sendFeatureVote().subscribe({
      next: (_data: any): void => {
        // do something
      },
      error: (error: HttpErrorResponse): void => {
        // do something
      }
    });

    this.subscriptions.push(feature_vote);
  }
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Me too answer (2.5): have the same issue
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Razzer