vite: async/await is not lowered for zone.js, so fakeAsync/tick cannot control awaits
Maintainer thường phản hồi trong vòng 1 ngày
Đá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
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).
- 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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của voidzero-dev/oxc-angular-compiler
-
Constructor param typed `ns.Foo` (namespace-qualified) compiles to ɵɵinvalidFactoryDepCó thể đã có người làm @edbzn đã nhận 1 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
voidzero-dev/oxc-angular-compiler#633 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
@defer doesn't lazy-load an imports entry written as forwardRef(() => X)Có thể đã có người làm @edbzn đã nhận 1 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
voidzero-dev/oxc-angular-compiler#632 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Project-wide preserveWhitespaces option is ignoredCó thể đã có người làm @edbzn đã nhận 1 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
voidzero-dev/oxc-angular-compiler#631 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Constructor overloads: factory and metadata read the first overload, not the implementationCó thể đã có người làm @edbzn đã nhận 1 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
voidzero-dev/oxc-angular-compiler#630 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
@Injectable deps entries written as [new Optional(), new Self(), Dep] inject the array as the tokenCó thể đã có người làm @edbzn đã nhận 1 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
voidzero-dev/oxc-angular-compiler#629 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của voidzero-dev/oxc-angular-compiler
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
haowjy/mars-agents#228 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
redlib-org/redlib#604 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
dividebysandwich/rust-dos#240 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
A-UI C-Bug S-Needs-Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
bevyengine/bevy#26330 ·
Maintainer thường phản hồi trong vòng 2 ngày