From 3fbc77c812d89cf861076b9dce70270d4c9dc6fc Mon Sep 17 00:00:00 2001 From: goodboy Date: Wed, 24 Jun 2026 13:34:37 -0400 Subject: [PATCH] Tighten `start_or_cancel`'s startup-RTE match The `'started' in rte.args[0]` check was too loose: it matched a child task's OWN `RuntimeError(...started...)` (not just trio's "child exited without calling task_status.started()"), and would `TypeError` on a non-`str` `args[0]`. Guard with `isinstance(..., str)` and match trio's exact wording so a real child error can't be demoted to `Cancelled` under cancellation. Review: PR #464 (copilot-pull-request-reviewer) https://github.com/goodboy/tractor/pull/464#pullrequestreview-4548203343 (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- tractor/trionics/_taskc.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tractor/trionics/_taskc.py b/tractor/trionics/_taskc.py index 13310ff1..7cb5fff6 100644 --- a/tractor/trionics/_taskc.py +++ b/tractor/trionics/_taskc.py @@ -340,7 +340,16 @@ async def start_or_cancel( if ( rte.args and - 'started' in rte.args[0] + isinstance(rte.args[0], str) + and + # match trio's *exact* "child exited without calling + # task_status.started()" wording — a bare `'started'` + # substring would also match a child task's OWN + # `RuntimeError(...started...)` and (under cancellation) + # demote it to a `Cancelled`, losing the real error. The + # `isinstance` guard also avoids a `TypeError` when + # `rte.args[0]` isn't a `str`. + 'child exited without calling' in rte.args[0] ): # re-raises the in-flight `trio.Cancelled` IFF we're # under effective cancellation; else a cheap no-op and