Skip to content

fetch HttpClient + signals is not triggering cdr #25985

Closed

Description

@zip-fa

Which @angular/* package(s) are the source of the bug?

common

Is this a regression?

Yes

Description

HttpClient withFetch() will not trigger CDR with nested queries coming from switchMap

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/angular-at-wvr9ue?file=src%2Fmain.ts

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Angular: 17.0.0-next.7
... animations, cli, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1700.0-next.7
@angular-devkit/build-angular   17.0.0-next.7
@angular-devkit/core            17.0.0-next.7
@angular-devkit/schematics      17.0.0-next.7
@angular/cdk                    17.0.0-next.5
@angular/material               17.0.0-next.6
@schematics/angular             17.0.0-next.7
rxjs                            7.4.0
typescript                      5.2.2
zone.js                         0.13.0

Anything else?

No response

Activity

  1. JeanMeche commented on Oct 8, 2023

    @JeanMeche
    Member

    Well, thank you for reporting that,

    this.client
      .get('https://random-data-api.com/api/beer/random_beer')
      .subscribe(() => {
        NgZone.assertInAngularZone();
      });

    Fails miserably when using the FetchBackend

    Edit: This bug only happens with the browser-esbuild builder.

  2. surajy93 commented on Oct 8, 2023

    @surajy93

    import { ChangeDetectorRef } from '@angular/core';

    // Inside your component constructor or method
    constructor(private cd: ChangeDetectorRef) { }

    // Inside your HTTP request subscription or switchMap
    this.http.get('your-url').subscribe((data) => {
    // Process data
    // Trigger change detection
    this.cd.detectChanges();
    });

  3. added this to the needsTriage milestone on Oct 8, 2023
  4. JeanMeche commented on Oct 8, 2023

    @JeanMeche
    Member

    cc @alan-agius4 If you have any idea why the builder changes the behaviour we can observe here.

    Edit: it's getting weirder every time i try to look into it, it seems to be caching related in serve mode.

    • cache=true + esbuild + serve = KO
    • cache=true + esbuild + build = OK
    • cache=false + esbuild + serve = OK
    • cache=true + webpack + serve = OK
  5. alan-agius4 commented on Oct 9, 2023

    @alan-agius4
    Collaborator

    Yeah, I know what is going on. I'll open a PR later today.

  6. removed this from the needsTriage milestone on Oct 9, 2023
  7. transferred this issue fromangular/angularon Oct 9, 2023
  8. self-assigned this
    on Oct 9, 2023
  9. added a commit that references this issue on Oct 9, 2023
    6ddcfc7
  10. added 3 commits that reference this issue on Oct 9, 2023
    968ee34
    b30b958
    c6ea256
  11. angular-automatic-lock-bot commented on Nov 9, 2023

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  12. locked and limited conversation to collaborators on Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions