You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
vite: async/await is not lowered for zone.js, so fakeAsync/tick cannot control awaits #641
@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'})exportclassAuthService{constructor(privatecognito: Cognito){}asynclogout(){awaitthis.cognito.signOutRedirectUrl();awaitthis.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.
Workaround today: Vite esbuild: { supported: { 'async-await': false } }. Under Vitest it also needs esbuild's var __async helper rewritten to a function declaration, because vi.mock hoisting moves async mock factories above it (__async is not a function).
Activity
fix(vite): downlevel async/await for zone.js like the Angular CLI (#642)