Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: event handler listen to ctx.Done #38

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

GoshaDo
Copy link
Contributor

@GoshaDo GoshaDo commented Jan 9, 2025

Pull Request

Description

Possible race condition on watcher.Stop() and stop()
Added listen to closure of watcher channel and stop the program

Before submitting this pull request, please ensure that you have completed the following tasks:

@GoshaDo GoshaDo requested a review from omri2001 January 11, 2025 15:27
@GoshaDo GoshaDo force-pushed the event-handler-listen-to-ctx-done branch from f90f747 to b285804 Compare January 11, 2025 15:29
@GoshaDo GoshaDo force-pushed the event-handler-listen-to-ctx-done branch from b285804 to 399a7e6 Compare January 11, 2025 16:26
}
}
log.Print("[event handler] stopped work, closing watcher")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoshaDo can explain how the race condition could happen ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If stop() is called, it will cancel the context (ctx). If the context is already canceled before watcher.Stop() completes, there could be race conditions or unexpected behavior.

Copy link

@adiludmer adiludmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment

@GoshaDo GoshaDo requested a review from adiludmer January 11, 2025 18:14
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.

3 participants