mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-10-26 13:16:24 +00:00
* fix(projects): make read_file_chunks cancellation-safe for worker handoffs Cancelling a project document read had three unsafe windows around the dedicated file-I/O worker: (1) a cancellation landing between the open worker completing and the result reaching the coroutine leaked the handle (the cleanup path never saw it); (2) the cleanup close could start while an admitted read was still running; (3) a repeated cancellation let the caller escape before the close worker settled (#7491). Gate every admitted operation with the existing await_drained primitive: cancellation is delivered only after the operation settles, the open result is retained in a list cell the moment the worker returns it (so the cleanup close always has the handle), and waiting for the next chunk via the yield stays immediately cancellable. Regression tests gate the real executor with asyncio events at the worker boundary (real files, no mocks): all three windows are red on unmodified main and green with the fix; the happy path is unchanged. The dispatch-spy promotion tests that import app.gateway.routers need the full backend dependency set and could not run in the minimal local env; they fail identically on unmodified main (verified). Fixes #7491 Co-authored-by: Jay Feng <jayfeng77@outlook.com> * test: fix _gated_offload return annotation to the unpacked tuple Review nit: the helper returns (calls, gated) and every call site unpacks it as a pair, but the annotation claimed list[str]. Type it as the tuple it actually returns. Co-authored-by: Jay Feng <jayfeng77@outlook.com> * test: pin missing-path FileNotFoundError in read_file_chunks Convergence item from the duplicate-pair verdict (#7493): the open-failure path must surface FileNotFoundError as-is — the cleanup finally skips the close because retained is empty (no handle was ever opened), rather than raising AttributeError from closing None. Co-authored-by: Jay Feng <jayfeng77@outlook.com> --------- Co-authored-by: Jay Feng <jayfeng77@outlook.com>