Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Ask for Feedback: Make `JSObject` / `JSFunction` calls be `throws`

Offen
#272 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
25/100
Issue-Typ
Feature
Klarheit
Muss geklärt werden
Aktivitätsstatus
Veraltet
Tech-Stack
javascript, swift, wasm
Bereich
api

Rechercherichtung

Das Issue nennt JSObject und JSFunction als die betroffenen APIs, gibt aber keinen Datei- oder Test-Einstiegspunkt an. Überprüfe ihre Aufrufimplementierungen und das bestehende .throws/.throwing-Verhalten, miss anschließend die Performance-Kompromisse und definiere Tests für auslösende und nicht auslösende Aufrufe, bevor du die nicht rückwärtskompatible API-Änderung entscheidest.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Every dynamic JS function calls can throw an exception, but the current JSObject and JSFunction are non-throws by default.
They can be throws by .throws or .throwing but it's still opt-in.

For example, if an exception is thrown during a JS function call but the call site in Swift side is not throws, the control unwinding wasm call frames without executing function epilogues even if there is do { } catch {} clause in Swift. And also in that case, defer blocks won't be called.

This behavior is quite tricky and unwinding wasm call frames without executing function epilogues can lead to memory and resource leak.

I'm going to introduce an API breaking change to make JSObject / JSFunction calls be throws in the next next release to improve the situation.

This change has a performance tradeoff as throws variants are typically a little bit slower than non-throwing variants. We should measure the amount of the penalty but it shouldn't be a big deal. We can make non throwing calls as an opt-in feature so that those who want best performance can satisfy their needs.

// Before
let foo = JSObject.global.document.getElementById!("foo")
let foo = try JSObject.global.document.throwing.getElementById!("foo")

// After
let foo = try JSObject.global.document.getElementById!("foo")
let foo = JSObject.global.document.nonthrowing.getElementById!("foo")

Let me know here if you have a strong objection 🙏 Thanks.

Vorherrschende Sprache
Swift
Sterne
986
Forks
76
Ø Merge
21 Std. 11 Min.
Gemergte PRs (30 T.)
4

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus swiftwasm/JavaScriptKit

Alle Issues in swiftwasm/JavaScriptKit

Ähnliche Issues

Weitere Issues zu Swift

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.