Skip to content

BridgeJS: fix codegen for async + throws exported methods#691

Merged
kateinoigakukun merged 1 commit intoswiftwasm:mainfrom
untitled-in-brackets:bugfix/bridgejs-async-throws-codegen
Mar 4, 2026
Merged

BridgeJS: fix codegen for async + throws exported methods#691
kateinoigakukun merged 1 commit intoswiftwasm:mainfrom
untitled-in-brackets:bugfix/bridgejs-async-throws-codegen

Conversation

@diederich
Copy link
Contributor

The render method handled isAsync and isThrows as mutually exclusive branches, so methods that were both async and throws only got the JSPromise.async wrapper without the explicit throws(JSException) type annotation on the closure. This caused the Swift compiler to infer throws(any Error) instead of throws(JSException), producing a build error.

Add a new branch for the combined case that explicitly annotates the closure with () async throws(JSException) [-> JSValue] in.

Made-with: Cursor by Ryan, pushed up and reviewed by me :-)

The render method handled isAsync and isThrows as mutually exclusive
branches, so methods that were both async and throws only got the
JSPromise.async wrapper without the explicit throws(JSException) type
annotation on the closure. This caused the Swift compiler to infer
throws(any Error) instead of throws(JSException), producing a build
error.

Add a new branch for the combined case that explicitly annotates the
closure with `() async throws(JSException) [-> JSValue] in`.

Made-with: Cursor
Copy link
Member

@kateinoigakukun kateinoigakukun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to overhaul async support using JSTypedClosure later anyway but let's fix this issue now

@kateinoigakukun kateinoigakukun merged commit bc05d2a into swiftwasm:main Mar 4, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants