vite: async/await is not lowered for zone.js, so fakeAsync/tick cannot control awaits
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- angular, javascript, typescript, vite
- Área
- build-system, testing
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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).
- Lenguaje dominante
- Rust
- Estrellas
- 244
- Forks
- 26
- Merge medio
- 23 h 16 min
- PR fusionados (30 d)
- 96
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de voidzero-dev/oxc-angular-compiler
-
@defer doesn't lazy-load an imports entry written as forwardRef(() => X)Posiblemente ocupada @edbzn la tomó hace 2 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
voidzero-dev/oxc-angular-compiler#632 ·
Los mantenedores suelen responder en 1 día
-
Dynamic host attribute values are rejected (and two local-compilation-only transform cases)Posiblemente ocupada @edbzn la tomó hace 2 días. Abierto
Dificultad 4/5 1-2 días Aptitud para principiantes 35/100
voidzero-dev/oxc-angular-compiler#627 ·
Los mantenedores suelen responder en 1 día
-
@Injectable deps entries written as [new Optional(), new Self(), Dep] inject the array as the tokenAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
voidzero-dev/oxc-angular-compiler#626 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 28/100
voidzero-dev/oxc-angular-compiler#623 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Support useDefineForClassFields: false (Class Field Lowering)Posiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
voidzero-dev/oxc-angular-compiler#73 · 11 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de voidzero-dev/oxc-angular-compiler
Issues similares
-
QuartoHub: have the Document name before the filename in the browser tabPosiblemente ocupada @cscheid la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
quarto-dev/q2#930 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
muse P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
HerringtonDarkholme/hd-lang#923 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
longbridge/gpui-kit#3712 ·
Los mantenedores suelen responder en 1 día
-
documentation enhancement SIEM
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
ADORSYS-GIS/wazuh-agent-status#265 ·
Los mantenedores suelen responder en 2 días