Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta
#272 2 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
5/5
Tempo estimado
Mais de uma semana
Facilidade para iniciantes
25/100
Tipo de issue
Funcionalidade
Clareza
Precisa de esclarecimento
Status de atividade
Estagnada
Stack de tecnologia
javascript, swift, wasm
Domínio
api

Direção de pesquisa

A issue nomeia JSObject e JSFunction como as APIs afetadas, mas não fornece nenhum arquivo ou ponto de entrada de teste. Revise suas implementações de chamadas e o comportamento existente de .throws/.throwing, depois meça o trade-off de desempenho e defina testes para chamadas que lançam exceções e que não lançam exceções antes de decidir a alteração incompatível da API.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Swift
Estrelas
986
Forks
76
Merge médio
21h 11min
PRs com merge (30d)
4

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de swiftwasm/JavaScriptKit

Todas as issues de swiftwasm/JavaScriptKit

Issues semelhantes

Mais issues de Swift

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.