napi backend: class-cluster return values lose their concrete API surface — NSURLSessionWebSocketTask arrives bridged as NSURLSessionTask
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 22/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- cpp, objective-c
- Bereich
- desktop-dev
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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/runtimes5b697b39, generic napi backend,TARGET_PLATFORM=macos, arm64NSURLSessionWebSocketTaskrequires macOS 10.15+; runtime-verified — this is wrapper resolution, not a metadata absence.
- Vorherrschende Sprache
- C++
- Sterne
- 27
- Forks
- 5
- Ø Merge
- 5 T. 11 Std.
- Gemergte PRs (30 T.)
- 12
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus NativeScript/runtimes
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 30/100
NativeScript/runtimes#111 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 32/100
NativeScript/runtimes#109 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 18/100
NativeScript/runtimes#108 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 40/100
NativeScript/runtimes#107 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 42/100
NativeScript/runtimes#106 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in NativeScript/runtimes
Ähnliche Issues
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 65/100
-
error not reported I/O low priority rt_lib
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
Maintainer antworten meist innerhalb von 1 Tag
-
[XLA] hlo/pass/README.md says passes implement Run; since the NVI change they implement RunImplOffen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 91/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
NVIDIA-RTX/NRI#312 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
Maintainer antworten meist innerhalb von 9 Tagen