Consider runtime warning when WeaveHandle is dropped without completion/cancellation #141
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
refactor
rust
technical-debt
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
navicore/patch-seq#141
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Background
PR #138 documents that weaves must be either:
has_morereturns false)strand.weave-cancelIf neither happens and the WeaveHandle is dropped, the spawned coroutine hangs forever.
Current State
The limitation is well-documented in
weave.rs:Problem
While documented, this is a silent resource leak that's easy to introduce accidentally:
Options to Consider
Option A: Auto-cancel on Drop (Implicit)
Pro: No leaks possible
Con: Hides programming errors, unexpected behavior
Option B: Warning on Drop (Diagnostic)
Track completion state in WeaveCtx, emit warning if dropped without completion:
Pro: Alerts developer to bug
Con: Runtime overhead, noisy in some valid patterns
Option C: Debug-only assertion
Pro: Catches bugs in development
Con: Silent in release builds
Option D: Static analysis via LSP lint (See related issue)
Lint rule to detect
strand.weavewithout matchingstrand.weave-cancelor completion loop.Pro: Catches at edit time
Con: Complex flow analysis, may have false positives
Option E: Keep documentation only (Current)
Pro: Simple, no runtime overhead
Con: Easy to miss in practice
Recommendation
Start with Option C (debug assertion) + Option D (LSP lint). This provides:
Acceptance Criteria
Related
Closing as won't fix after analysis.
Rationale:
The implementation cost is high relative to the benefit:
WeaveHandleandWeaveCtxare the same type (Value::WeaveCtx) sharing Arc'd channelsWhat we have instead:
strand.weave drop→ error (catches immediate drops)strand.resume drop drop drop→ warning (catches unchecked resumes)The lint rules catch obvious cases at edit time (better than runtime warnings), and #142 will provide more sophisticated static analysis. After #139, even if a weave hangs, it doesn't cause UB - the coroutine just blocks harmlessly.