Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

TS SDK: `Result` errors are serialized with the `ok` type (instance crash)

未关闭 适合新手
#6,122 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@Tyagiquamar 已经在做这个了。

开始于 2026年10月11日。

  • #6142 来自 @Tyagiquamar —— 未关闭
  • #6148 来自 @aasoni —— 未关闭

评估

难度
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 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

clockworklabs/SpacetimeDB 的其他 Issue

查看 clockworklabs/SpacetimeDB 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。