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
- 平均マージ
- 1日 57分
- マージ済み PR(30日)
- 103
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
voidzero-dev/oxc-angular-compiler のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 28/100
voidzero-dev/oxc-angular-compiler#623 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Support useDefineForClassFields: false (Class Field Lowering)対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
voidzero-dev/oxc-angular-compiler#73 · コメント 11 件 ·
メンテナーはふだん 1 日以内に返信
-
Angular 21.2.0 + @oxc-angular/vite 0.0.7 SSR runtime parity regressions (RouterLinkActive, Forms DI, Apollo DI) require app-level shims再び着手できるかも @Brooooooklyn が 237 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
voidzero-dev/oxc-angular-compiler#61 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Angular 21.2.0 + @oxc-angular/vite 0.0.7 SSR: AngularNodeAppEngine is unusable (missing app-engine manifest)再び着手できるかも @Brooooooklyn が 237 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
voidzero-dev/oxc-angular-compiler#60 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
voidzero-dev/oxc-angular-compiler の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 1 日以内に返信
-
type: enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
franciscoBSalgueiro/en-croissant#1061 ·
メンテナーはふだん 3 日以内に返信
-
chore good first issue macros spire
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
groupmod -U: members change in /etc/group but not in /etc/gshadow対応中かも @jayhemnani9910 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 1 日以内に返信