Skip to content

fix: avoid typed Zip completion deadlocks - #405

Open
pentaoa wants to merge 1 commit into
samber:mainfrom
pentaoa:fix/typed-zip-completion-deadlock
Open

pentaoa wants to merge 1 commit into
samber:mainfrom
pentaoa:fix/typed-zip-completion-deadlock

Conversation

@pentaoa

@pentaoa pentaoa commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

When a completed input still has buffered values, Zip2Zip6 can emit the final tuple and then deadlock during completion. Their ZipWith1ZipWith5 implementations call CompleteWithContext while holding the queue mutex, and completion synchronously runs teardown, which needs the same mutex. Release the mutex before completing, as ZipAll already does.

This follows #381, which fixed premature unsubscription; it addresses the remaining typed-Zip completion deadlock related to #193. The regression waits until subscription setup has returned before draining a completed input, so it deterministically times out on the current main branch. Tests cover all five typed arities and each short-input position, asynchronous futures, context propagation, cancellation, error cleanup, and unsubscribe from the next callback. Operator documentation describes when buffered inputs are exhausted.

Validation: the new regressions and go test ./... pass locally on Go 1.25; the complete golangci-lint run reports zero issues and the two changed Go files pass the license-header check. Linux CI passes on Go 1.18–1.26 and stable, including make test with the race detector across the workspace. Lint, docs, CodeQL and Bearer also pass. The two Trivy checks fail because .trivyignore is missing; the main-branch run has the same failure.

AI assistance: OpenAI Codex implemented the change, wrote the regression tests, and ran the reported local checks.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.81%. Comparing base (069da65) to head (c84524a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #405      +/-   ##
==========================================
+ Coverage   66.75%   66.81%   +0.06%     
==========================================
  Files          96       96              
  Lines        7973     7988      +15     
==========================================
+ Hits         5322     5337      +15     
  Misses       2650     2650              
  Partials        1        1              
Flag Coverage Δ
unittests 66.81% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants