BridgeJS: Remove forced capture workaround in async thunk body closures once swiftlang/swift#89715 lands
@krodak đang làm issue này rồi.
Từ ngày 10/6/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Tracks removal of the workaround introduced in #760.
Context
A zero-parameter async throws(JSException) export generates a captureless _bjs_makePromise body closure, which lowers via thin_to_thick_function and miscompiles on Wasm (swiftlang/swift#89320): the thrown error is corrupted across the async unwind, trapping in Promise_reject or rejecting with a garbage value. #760 works around this at the codegen level by forcing a capture in the emitted body closure (the capture must also be read in the body, since an unread capture list entry is dropped by capture analysis and the closure stays thin):
let __bjs_capture = 0
return _bjs_makePromise(resolve: Promise_resolve_SS, reject: Promise_reject) { [__bjs_capture] () async throws(JSException) -> String in
_ = __bjs_capture
return try await ping()
}
What to do once the compiler fix ships
The proper fix is swiftlang/swift#89715 (IRGen: fix async typed throws miscompiles on Wasm). Once it is available in the oldest Swift toolchain JavaScriptKit supports:
- Remove
asyncThrowsBodyForcesCaptureand the forced-capture emission fromExportedThunkBuilderinPlugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift. - Regenerate snapshots and the AoT-committed bindings.
- Keep the
zeroArgAsyncThrowsend-to-end regression test as the guard that the reject path still works without the workaround.
- Ngôn ngữ chính
- Swift
- Star
- 986
- Fork
- 76
- Merge trung bình
- 21 giờ 11 phút
- Pull request đã merge (30 ngày)
- 4
Hướng dẫn đóng góp
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 swiftwasm/JavaScriptKit
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
swiftwasm/JavaScriptKit#793 ·
-
swiftwasm/JavaScriptKit#785 · 1 người được giao ·
-
[SwiftBuild] Preserve duplicate archive members when SwiftBuild expands static archives for linking Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
swiftwasm/JavaScriptKit#781 · 3 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
swiftwasm/JavaScriptKit#773 ·
-
swiftwasm/JavaScriptKit#767 · 1 người được giao ·
Tất cả issue của swiftwasm/JavaScriptKit
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
maxgoedjen/secretive#840 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
manaflow-ai/cmux#13763 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
openwallet-foundation/multipaz#2028 ·