TS SDK: `Result` errors are serialized with the `ok` type (instance crash)
维护者通常 1 天内回复
评估
- 难度
- 1/5
- 预计耗时
- 1 小时以内
- 新手友好度
- 85/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- devtools
调研方向
该错误位于 crates/bindings-typescript/src/lib/algebraic_type.ts 约第 655-662 行,serializeErr 是由 ty.variants[0] 而不是 ty.variants[1] 构建的。请阅读周围的 result 序列化器以确认这一模式,然后添加一个测试,序列化一个 ok 和 err 类型不同的 t.result,例如 t.result(SomeObject, t.string()) 搭配 { err: 'nope' }。当错误字符串被序列化为字符串且测试通过时,即完成。
由索引模型根据 Issue 内容生成。
描述
Version: spacetimedb (npm) 2.11.0, still on master e596513
Where: crates/bindings-typescript/src/lib/algebraic_type.ts ~L655-662
const serializeOk = AlgebraicType.makeSerializer(ty.variants[0].algebraicType, typespace);
const serializeErr = AlgebraicType.makeSerializer(ty.variants[0].algebraicType, typespace); // ← should be variants[1]
Repro: a TS procedure (or anything else returning a result) declared as t.result(SomeObject, t.string()) that
returns { err: 'nope' }.
Actual: TypeError: Cannot read properties of undefined (reading 'length') in writeString, and the instance
reports a fatal error. The error string is written with the SomeObject serializer.
Expected: the error is serialized as a string.
It only works by accident when the ok and err types are the same (e.g. t.result(t.string(), t.string())).
Fix: ty.variants[1].algebraicType on the serializeErr line.
- 主要语言
- Rust
- 星标
- 25.3k
- 派生
- 1.1k
- 平均合并
- 4 天 13 小时
- 30 天内合并 PR
- 44
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
clockworklabs/SpacetimeDB 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
clockworklabs/SpacetimeDB#6146 ·
维护者通常 1 天内回复
-
TS SDK: `t.result()` is typed `Ok | Err`, but the runtime expects `{ ok } | { err }`可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
clockworklabs/SpacetimeDB#6127 ·
维护者通常 1 天内回复
-
TS SDK: `ctx.http.fetch` throws for status codes the `statuses` package doesn't know可能已有人在做 @kshanxs 于 1 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 82/100
clockworklabs/SpacetimeDB#6126 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
clockworklabs/SpacetimeDB#6124 ·
维护者通常 1 天内回复
-
TS SDK: `ctx.http.fetch` splits header values that contain commas可能已有人在做 @kshanxs 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
clockworklabs/SpacetimeDB#6123 ·
维护者通常 1 天内回复
查看 clockworklabs/SpacetimeDB 的全部 Issue
相似的 Issue
-
area::tern difficulty::easy good first issue kind::cleanup triage::ready
难度 1/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 76/100
eclipse-zenoh/zenoh#2842 · 2 条评论 ·
维护者通常 1 天内回复
-
中文字符导致软件崩溃未关闭bug
难度 2/5 1-3 小时 新手友好度 62/100
Y-ASLant/ElegantClipboard#172 ·
-
bug documentation
难度 2/5 1-3 小时 新手友好度 78/100
SaboLabs/soroban-devkit#341 ·
维护者通常 1 天内回复
-
agent:sonnet-high enhancement priority: P2 ready-for-agent
难度 2/5 1-3 小时 新手友好度 82/100
shep-pm/shep-kelpie#652 ·
维护者通常 1 天内回复