A first yield that is not a task leaks the generator
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 65/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- javascript, rust
- Bereich
- backend
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 36
- Forks
- 20
- Ø Merge
- 20 Std. 52 Min.
- Gemergte PRs (30 T.)
- 4
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 microsoft/duroxide-node
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 58/100
microsoft/duroxide-node#18 ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 28/100
microsoft/duroxide-node#16 ·
Alle Issues in microsoft/duroxide-node
Ähnliche Issues
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
QuantEcon/lecture-python-programming#642 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Missing repro Platform: Android
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
software-mansion/react-native-reanimated#10816 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
[Suggestion]: Document that useFormStatus works with a preventDefault-ed onSubmit + startTransitionOffentype: documentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 2 Tagen
-
area:docs bug triage:confirmed
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
Cotal-AI/Cotal#2875 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
keithamus/css-minify-tests#304 ·
Maintainer antworten meist innerhalb von 1 Tag