Skip to content

Fix race condition in event stream channel handling#6455

Closed
utafrali wants to merge 2 commits into
woodpecker-ci:mainfrom
utafrali:fix/issue-6454-woodpecker-server-panics-crashes-at-time
Closed

Fix race condition in event stream channel handling#6455
utafrali wants to merge 2 commits into
woodpecker-ci:mainfrom
utafrali:fix/issue-6454-woodpecker-server-panics-crashes-at-time

Conversation

@utafrali

Copy link
Copy Markdown
Contributor

Fixes #6454

We were getting panics when clients disconnected from SSE feeds because the code was closing the channel while goroutines could still be trying to send on it.

The fix removes the explicit close() calls and refactors the select statements so that context cancellation and channel sends happen atomically. If the context is cancelled, we skip the send. The channel gets garbage collected naturally after all goroutines exit the context.

Added a concurrent stress test to make sure this doesn't happen again.

Comment thread server/pubsub/memory/pub_test.go
@6543 6543 added bug Something isn't working server labels Apr 16, 2026
@woodpecker-bot

This comment was marked as off-topic.

@woodpecker-bot

woodpecker-bot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Surge PR preview deployment was removed

@utafrali

Copy link
Copy Markdown
Contributor Author

Done, pushed the fix.

@6543

6543 commented Apr 16, 2026

Copy link
Copy Markdown
Member

now I dont know why there are tow pulls working on the same issue by the same people either authored or reviewed!?!?

-> #6456

@utafrali

Copy link
Copy Markdown
Contributor Author

Ah yeah, I'll close this since #6456 is already on it.

@utafrali utafrali closed this Apr 16, 2026
@6543

6543 commented Apr 20, 2026

Copy link
Copy Markdown
Member

still thanks for the fix

@taylorsilva

Copy link
Copy Markdown

FYI, OP is a bot: concourse/concourse#9532 (comment)

@6543 6543 added duplicate and removed bug Something isn't working server labels Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

woodpecker server panics & crashes at times

5 participants