Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

vite: async/await is not lowered for zone.js, so fakeAsync/tick cannot control awaits

未關閉
#641 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@edbzn 已經在處理了。

開始於 2026年10月25日。

  • #642 來自 @edbzn —— 未關閉

評估

難度
4/5
預估耗時
3-5 天
新手友好度
35/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
angular, javascript, typescript, vite

研究方向

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 transformForBrowser with 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's var __async helper rewritten to a function declaration, because vi.mock hoisting moves async mock factories above it (__async is not a function).
主要語言
Rust
星號
244
分支
26
平均合併
23 小時 16 分鐘
30 天內合併 PR
96

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

voidzero-dev/oxc-angular-compiler 的其他 Issue

查看 voidzero-dev/oxc-angular-compiler 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。