Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#641 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@edbzn đang làm issue này rồi.

Từ ngày 25/10/2026.

  • #642 của @edbzn — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
angular, javascript, typescript, vite
Lĩnh vực
build-system, testing

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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).
Ngôn ngữ chính
Rust
Star
244
Fork
26
Merge trung bình
1 ngày 16 phút
Pull request đã merge (30 ngày)
87

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của voidzero-dev/oxc-angular-compiler

Tất cả issue của voidzero-dev/oxc-angular-compiler

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.