napi backend: class-cluster return values lose their concrete API surface — NSURLSessionWebSocketTask arrives bridged as NSURLSessionTask

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

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
5/5
Tempo estimado
Mais de uma semana
Facilidade para iniciantes
22/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
cpp, objective-c
Domínio
desktop-dev

Direção de pesquisa

The problem is in how the napi backend picks a JS wrapper for a returned Objective-C object: the isa-chain walk stops at the first metadata-registered class, which lands above the declared return type. Start from that resolution step and reproduce with NSURLSession.sharedSession.webSocketTaskWithURL, checking whether sendMessageCompletionHandler is present on the returned wrapper. Done means the wrapper exposes the NSURLSessionWebSocketTask members without the setPrototypeOf workaround; the fix design needs maintainer input first.

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

Descrição

Summary

When a bridged API returns a private class-cluster subclass, the JS wrapper is resolved by walking the real isa chain to the first metadata-registered class — so it lands below the declared return type and the concrete API surface is unreachable from JS.

NSURLSession.sharedSession.webSocketTaskWithURL(...) returns __NSURLSessionWebSocketTask (isa chain: __NSURLSessionWebSocketTask → __NSCFLocalSessionTask → NSURLSessionTask → NSObject). NSURLSessionWebSocketTask is metadata-registered and fully bridged — its prototype has every member — and task.isKindOfClass(NSURLSessionWebSocketTask) is true, but the returned wrapper exposes only NSURLSessionTask members: sendMessageCompletionHandler and receiveMessageWithCompletionHandler are undefined, so calls throw TypeError. Private cluster classes can't enter public-header metadata, so the ws level is never reached by the isa walk.

Expected

When isa-walk resolution lands on an ancestor of the metadata-declared return type, the wrapper could be built from the declared type; alternatively, an opt-in way to repoint a wrapper to a registered subclass the object isKindOfClass:es would cover the same ground.

Workaround we run today: Object.setPrototypeOf(task, NSURLSessionWebSocketTask.prototype) when the ws members are missing — every member then dispatches correctly, including closeCode/closeReason. A minimal regression check for a fix is that the returned task exposes sendMessageCompletionHandler without the repoint.

Environment

  • NativeScript/runtimes 5b697b39, generic napi backend, TARGET_PLATFORM=macos, arm64
  • NSURLSessionWebSocketTask requires macOS 10.15+; runtime-verified — this is wrapper resolution, not a metadata absence.
Linguagem predominante
C++
Estrelas
27
Forks
5
Merge médio
5d 11h
PRs com merge (30d)
12

Preparar o ambiente

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 NativeScript/runtimes

Todas as issues de NativeScript/runtimes

Issues semelhantes

Mais issues de C++

Receba novas issues na sua caixa de entrada

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