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

fetch HttpClient + signals is not triggering cdr #25985

Closed
zip-fa opened this issue Oct 8, 2023 · 5 comments · Fixed by #25986
Closed

fetch HttpClient + signals is not triggering cdr #25985

zip-fa opened this issue Oct 8, 2023 · 5 comments · Fixed by #25986

Comments

@zip-fa
Copy link

zip-fa commented Oct 8, 2023

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

@JeanMeche
Copy link
Member

JeanMeche commented Oct 8, 2023

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.

@surajy93
Copy link

surajy93 commented Oct 8, 2023

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();
});

@ngbot ngbot bot added this to the needsTriage milestone Oct 8, 2023
@JeanMeche
Copy link
Member

JeanMeche commented Oct 8, 2023

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

@alan-agius4
Copy link
Collaborator

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

@ngbot ngbot bot removed this from the needsTriage milestone Oct 9, 2023
@alan-agius4 alan-agius4 transferred this issue from angular/angular Oct 9, 2023
@alan-agius4 alan-agius4 self-assigned this Oct 9, 2023
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Oct 9, 2023
…using vite dev-server with caching enabled

Prior to this change, async/await in external packages were not being correctly downlevelled when using vite dev-server with cache enabled.

Closes angular#25985
alan-agius4 added a commit that referenced this issue Oct 9, 2023
…using vite dev-server with caching enabled

Prior to this change, async/await in external packages were not being correctly downlevelled when using vite dev-server with cache enabled.

Closes #25985
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Oct 10, 2023
…using vite dev-server with caching enabled

Prior to this change, async/await in external packages were not being correctly downlevelled when using vite dev-server with cache enabled.t checkout

Closes angular#25985

(cherry picked from commit 968ee34)
alan-agius4 added a commit that referenced this issue Oct 10, 2023
…using vite dev-server with caching enabled

Prior to this change, async/await in external packages were not being correctly downlevelled when using vite dev-server with cache enabled.t checkout

Closes #25985

(cherry picked from commit 968ee34)
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants