A first yield that is not a task leaks the generator
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 65/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript, rust
- 领域
- backend
调研方向
Start at lib/duroxide.js:61, where JS stores the generator before the first step, and trace driveStep's handling of the yielded value. Then read src/handlers.rs, the parse in call_create_blocking (301-312) and the dispose guard (801-812) that only fires once set_gen_id was called. Reproduce with an orchestration whose first yield is yield 42; done means the orchestration fails as it does now but disposeGenerator runs and the map entry is gone.
由索引模型根据 Issue 内容生成。
描述
Summary
If the first value that an orchestration yields is not a valid task, the generator object stays in the generators map for the life of the process.
Where
- JS stores the generator before the first step: https://github.com/microsoft/duroxide-node/blob/9fb6b853f6fa0d84da81e761e4c0bf288217f70d/lib/duroxide.js#L61
- Rust parses the step result in
call_create_blocking. On a parse error it returns before it knows the generator ID: https://github.com/microsoft/duroxide-node/blob/9fb6b853f6fa0d84da81e761e4c0bf288217f70d/src/handlers.rs#L301-L312 - The guard disposes a generator only when its ID was set: https://github.com/microsoft/duroxide-node/blob/9fb6b853f6fa0d84da81e761e4c0bf288217f70d/src/handlers.rs#L801-L812
How it fails
- The orchestration yields something that is not a task as its first step. Examples are
yield 42and a Promise yielded by mistake. - JS returns
{ status: 'yielded', generatorId, task: 42 }. - Rust fails with
Invalid generator step result: ...and the orchestration fails. This part is right. guard.set_gen_idwas never called, sodisposeGeneratoris never called. The generator, its closure and its context stay in the map.
A bad value in a later step is handled: by then the guard knows the ID.
How this was checked
Read in the code. The Python SDK has the same code path, and a run there shows the leak: microsoft/duroxide-python#19.
Suggested fix
Either of these:
- In
driveStep, check that the yielded value is a task. If it is not, delete the generator and return an error. - In Rust, read
generatorIdfrom the raw JSON before the task is parsed, and dispose the generator on a parse error.
Tracked in microsoft/duroxide#55.
- 主要语言
- JavaScript
- 星标
- 36
- 派生
- 20
- 平均合并
- 20 小时 52 分钟
- 30 天内合并 PR
- 4
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/duroxide-node 的其他 Issue
-
bug
难度 4/5 3-5 天 新手友好度 58/100
microsoft/duroxide-node#18 ·
-
难度 5/5 一周以上 新手友好度 28/100
microsoft/duroxide-node#16 ·
查看 microsoft/duroxide-node 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 80/100
-
documentation
难度 1/5 1 小时以内 新手友好度 88/100
githubnext/gh-aw-workshop#4251 ·
维护者通常 1 天内回复
-
customer-support needs-triage Platform(Default)
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
Leonxlnx/taste-skill#129 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100