vite: async/await is not lowered for zone.js, so fakeAsync/tick cannot control awaits
維護者通常 1 天內回覆
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- angular, javascript, typescript, vite
- 領域
- build-system, testing
研究方向
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.
由索引模型根據 Issue 內容生成。
描述
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).
- 主要語言
- Rust
- 星號
- 244
- 分支
- 26
- 平均合併
- 23 小時 16 分鐘
- 30 天內合併 PR
- 96
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
voidzero-dev/oxc-angular-compiler 的其他 Issue
-
@defer doesn't lazy-load an imports entry written as forwardRef(() => X)可能已有人在做 @edbzn 於 2 天前認領。 未關閉
難度 4/5 3-5 天 新手友好度 35/100
voidzero-dev/oxc-angular-compiler#632 ·
維護者通常 1 天內回覆
-
Dynamic host attribute values are rejected (and two local-compilation-only transform cases)可能已有人在做 @edbzn 於 2 天前認領。 未關閉
難度 4/5 1-2 天 新手友好度 35/100
voidzero-dev/oxc-angular-compiler#627 ·
維護者通常 1 天內回覆
-
@Injectable deps entries written as [new Optional(), new Self(), Dep] inject the array as the token未關閉
難度 4/5 3-5 天 新手友好度 52/100
voidzero-dev/oxc-angular-compiler#626 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 28/100
voidzero-dev/oxc-angular-compiler#623 · 1 則留言 ·
維護者通常 1 天內回覆
-
Support useDefineForClassFields: false (Class Field Lowering)可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 5/5 一週以上 新手友好度 35/100
voidzero-dev/oxc-angular-compiler#73 · 11 則留言 ·
維護者通常 1 天內回覆
查看 voidzero-dev/oxc-angular-compiler 的全部 Issue
相似的 Issue
-
documentation enhancement SIEM
難度 2/5 1-3 小時 新手友好度 82/100
ADORSYS-GIS/wazuh-agent-status#265 ·
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 65/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 83/100
manuscript-lang/manuscript#1629 ·
維護者通常 1 天內回覆
-
autofixer: follow-up
難度 2/5 1-3 小時 新手友好度 76/100
tursodatabase/turso#10885 ·
維護者通常 1 天內回覆
-
🐞 bug
難度 2/5 1-3 小時 新手友好度 75/100
nannou-org/gantz#475 ·
維護者通常 1 天內回覆