napi backend: class-cluster return values lose their concrete API surface — NSURLSessionWebSocketTask arrives bridged as NSURLSessionTask
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 22/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- cpp, objective-c
- 领域
- desktop-dev
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- C++
- 星标
- 27
- 派生
- 4
- 平均合并
- 5 天 11 小时
- 30 天内合并 PR
- 12
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
NativeScript/runtimes 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 30/100
NativeScript/runtimes#111 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 32/100
NativeScript/runtimes#109 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 18/100
NativeScript/runtimes#108 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 40/100
NativeScript/runtimes#107 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 42/100
NativeScript/runtimes#106 ·
维护者通常 1 天内回复
查看 NativeScript/runtimes 的全部 Issue
相似的 Issue
-
bug module:nodes tests
难度 2/5 1-3 小时 新手友好度 78/100
rocketride-org/rocketride-server#3020 ·
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
pocoproject/poco#5636 ·
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 72/100
microsoft/cppwinrt#1646 · 7 条评论 ·
维护者通常 1 天内回复