vite: async/await is not lowered for zone.js, so fakeAsync/tick cannot control awaits
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- angular, javascript, typescript, vite
- Bereich
- build-system, testing
Rechercherichtung
Start by reading #607’s transformForBrowser and lowerAsync, then inspect the Vite plugin transform path described in the issue. Reproduce the failure with the supplied zone.js and TestBed example, and check whether lowering async functions restores flushMicrotasks() behavior. Done means the test passes with the plugin’s chosen zone.js handling; an open linked pull request #642 shows work is already underway.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
@oxc-angular/vite leaves async/await native. zone.js can't patch native await, so in a zone-based app (and in zone-based tests) fakeAsync + tick()/flushMicrotasks() no longer drive code that awaits, and change detection after an await relies on the native promise instead of a zone task. The Angular CLI (esbuild supported: { 'async-await': false } when zone.js is in the polyfills) and Analog (supportedBrowsers → Angular's JavaScriptTransformer) both lower async to generators for this reason.
We hit it moving ~160 Vitest projects from @analogjs/vite-plugin-angular to @oxc-angular/vite: specs like the one below started failing.
Reproduction
// service.ts
@Injectable({ providedIn: 'root' })
export class AuthService {
constructor(private cognito: Cognito) {}
async logout() {
await this.cognito.signOutRedirectUrl();
await this.cognito.signOut();
}
}
// service.spec.ts (zone.js + TestBed)
it('signs out', fakeAsync(() => {
service.logout();
flushMicrotasks();
expect(cognito.signOut).toHaveBeenCalled(); // fails with @oxc-angular/vite, passes with Analog / Angular CLI
}));
Actual
signOut is never called inside the fakeAsync zone: the second await resumes on a native microtask the zone doesn't track.
Expected (Angular CLI / Analog)
async functions are emitted as generators (__async(this, null, function* () { ... })), so flushMicrotasks() runs both awaits and the assertion passes.
Notes
- #607 adds
transformForBrowserwith exactly this lowering (lowerAsync), but the Vite plugin doesn't call it. Wiring it into the plugin's transform when zone.js is in use (or behind an option) would close this. - Workaround today: Vite
esbuild: { supported: { 'async-await': false } }. Under Vitest it also needs esbuild'svar __asynchelper rewritten to a function declaration, becausevi.mockhoisting moves async mock factories above it (__async is not a function).
- Vorherrschende Sprache
- Rust
- Sterne
- 244
- Forks
- 26
- Ø Merge
- 1 T. 16 Min.
- Gemergte PRs (30 T.)
- 87
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus voidzero-dev/oxc-angular-compiler
-
Constructor param typed `ns.Foo` (namespace-qualified) compiles to ɵɵinvalidFactoryDepEvtl. vergeben @edbzn hat das vor 1 Tag übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 25/100
voidzero-dev/oxc-angular-compiler#633 ·
Maintainer antworten meist innerhalb von 1 Tag
-
@defer doesn't lazy-load an imports entry written as forwardRef(() => X)Evtl. vergeben @edbzn hat das vor 1 Tag übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
voidzero-dev/oxc-angular-compiler#632 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Project-wide preserveWhitespaces option is ignoredEvtl. vergeben @edbzn hat das vor 1 Tag übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
voidzero-dev/oxc-angular-compiler#631 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Constructor overloads: factory and metadata read the first overload, not the implementationEvtl. vergeben @edbzn hat das vor 1 Tag übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
voidzero-dev/oxc-angular-compiler#630 ·
Maintainer antworten meist innerhalb von 1 Tag
-
@Injectable deps entries written as [new Optional(), new Self(), Dep] inject the array as the tokenEvtl. vergeben @edbzn hat das vor 1 Tag übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
voidzero-dev/oxc-angular-compiler#629 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in voidzero-dev/oxc-angular-compiler
Ähnliche Issues
-
A-UI C-Bug S-Needs-Triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
bevyengine/bevy#26330 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
chipsalliance/caliptra-sw#4335 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
aaif-goose/goose#13158 ·
Maintainer antworten meist innerhalb von 1 Tag
-
agent enhancement provider:anthropic providers triaged
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
can1357/oh-my-pi#17148 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
A-documentation good first issue
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
rust-lang/rust-clippy#17926 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag