Skip to content

Conversation

@amyssnippet
Copy link
Contributor

What I did

  • Fixed an issue where docker compose up --watch could become unresponsive after a large number of file changes (e.g., after a branch switch).
  • Ensured all watcher and sync goroutines and channels are robustly closed on context cancellation or error.
  • Added explicit logging for large batches and context cancellation to prevent stuck processes and ensure graceful shutdown on Ctrl-C.

Related issue

This PR addresses an issue where docker compose up --watch could become unresponsive after a large number of file changes (such as after a branch switch), causing logs to stop and Ctrl-C to not exit cleanly. The issue is #13136 . The fix ensures that all watcher and sync goroutines and channels are robustly closed on context cancellation or error, and adds explicit logging for large batches and context cancellation. This prevents the process from getting stuck and ensures graceful shutdown, even after large file change events.

By fixing:

  • I improved the shutdown logic in the watcher and sync system, ensuring all goroutines and channels are closed on context cancellation or error.
  • I added explicit logging for large file change batches and for context cancellation.
  • The patch directly addresses the symptoms described: logs stopping, Ctrl-C not exiting, and the process getting stuck after a large batch of file changes (such as after a branch switch).

select {
case <-ctx.Done():
options.LogTo.Log(api.WatchLogger, "Watch disabled")
options.LogTo.Log(api.WatchLogger, "Watch disabled (context canceled)")
Copy link
Contributor

Choose a reason for hiding this comment

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

"context" doesn't make any sense for end-user

ctx, cancel := context.WithCancel(ctx)
defer cancel()

// debounce and group filesystem events so that we capture IDE saving many files as one "batch" event
Copy link
Contributor

Choose a reason for hiding this comment

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

why remove this comment?

case batch := <-batchEvents:
case batch, ok := <-batchEvents:
if !ok {
options.LogTo.Log(api.WatchLogger, "Watch event channel closed")
Copy link
Contributor

Choose a reason for hiding this comment

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

WatchLogger is used to provide end-user message on the TUI, we should not refer to technical / implementation details

@amyssnippet
Copy link
Contributor Author

@ndeloof Thank you for the review! I've addressed your feedback on all comments in the latest commit

ndeloof
ndeloof previously approved these changes Jan 19, 2026
@ndeloof ndeloof enabled auto-merge (rebase) January 19, 2026 14:37
auto-merge was automatically disabled January 19, 2026 15:08

Head branch was pushed to by a user without write access

}

err = s.ensureImagesExists(ctx, project, options.Build, options.QuietPull)
prepareNetworks(project)
Copy link
Contributor

Choose a reason for hiding this comment

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

unrelated changes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i just tried to fix an issue, i just changed reorders the create function to ensure networks and volumes are provisioned before building images, which fixes a test failure

Copy link
Contributor

Choose a reason for hiding this comment

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

AFAICT this "fix" is unrelated to the current PR, and I can't see a test failure on main branch. Please avoid such undocumented changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, i have reverted back the irrelevant changes, take a look now and lets try running workflows.

@amyssnippet amyssnippet requested a review from ndeloof January 19, 2026 17:17
}

err = s.ensureImagesExists(ctx, project, options.Build, options.QuietPull)
prepareNetworks(project)
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAICT this "fix" is unrelated to the current PR, and I can't see a test failure on main branch. Please avoid such undocumented changes.

@amyssnippet amyssnippet force-pushed the main branch 2 times, most recently from 52025fd to 3f43fdc Compare January 20, 2026 07:03
@amyssnippet amyssnippet requested a review from ndeloof January 20, 2026 07:04
@ndeloof
Copy link
Contributor

ndeloof commented Jan 20, 2026

You PR is now mixing changes from upstream. Please squash commit and prefer rebase over merge from main

Ensured all watcher and sync goroutines and channels are robustly closed on context cancellation or error.
Added explicit logging for large batches and context cancellation to prevent stuck processes and ensure graceful shutdown on Ctrl-C.

Signed-off-by: Amol Yadav <amyssnipet@yahoo.com>
@amyssnippet
Copy link
Contributor Author

@ndeloof now??
i rebased all changes related to the issue i choose to solve

@ndeloof ndeloof enabled auto-merge (rebase) January 20, 2026 07:24
@ndeloof ndeloof merged commit b92b87d into docker:main Jan 20, 2026
24 checks passed
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