Skip to content

Conversation

@goller
Copy link
Collaborator

@goller goller commented Sep 17, 2025

Previously, we were only waiting for a single printer to complete. In multi-project builds we need to wait for all to finish.

@goller goller force-pushed the fix/printer-hanging branch from eb9d58b to f506e90 Compare September 17, 2025 23:20
@goller goller force-pushed the fix/printer-hanging branch from 3dbc622 to f6d4cb6 Compare September 17, 2025 23:29
Comment on lines 430 to 429
for range projectIDs {
fmt.Fprintf(os.Stderr, "**waiting for one printer Wait***\n")
_ = printer.Wait()
Copy link
Contributor

Choose a reason for hiding this comment

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

The loop is calling printer.Wait() once for each project ID, but this doesn't match the actual number of printers that were added. This could lead to incorrect behavior since Wait() is designed to be called exactly once per added printer.

Instead of iterating over projectIDs, consider:

  1. Tracking the number of printers added during execution and using that count for the loop, or
  2. Modifying the SharedPrinter implementation to handle multiple Wait() calls correctly

The current approach might cause issues with synchronization or resource cleanup if the number of project IDs doesn't match the number of printers that were actually added.

Suggested change
for range projectIDs {
fmt.Fprintf(os.Stderr, "**waiting for one printer Wait***\n")
_ = printer.Wait()
for i := 0; i < printer.Count(); i++ {
_ = printer.Wait()

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Previously, we were only waiting for a single printer to complete.
In multi-project builds we need to wait for all to finish.

Co-authored-by: Iris Scholten <ischolten.is@gmail.com>
Signed-off-by: Chris Goller <goller@gmail.com>
@goller goller force-pushed the fix/printer-hanging branch from f6d4cb6 to 7b2694f Compare September 17, 2025 23:48
@goller goller merged commit 8f2037f into main Sep 17, 2025
8 checks passed
@goller goller deleted the fix/printer-hanging branch September 17, 2025 23:49
Comment on lines +428 to +430
for range projectIDs {
_ = printer.Wait()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This change may cause a panic with 'negative WaitGroup counter' since printer.Wait() calls w.wg.Done() internally. Calling it multiple times (once per project ID) will decrement the counter beyond its initial value.

The solution should ensure that the number of Wait() calls matches the number of times the printer was added to the WaitGroup. Consider either:

  1. Tracking how many times the printer was added and calling Wait() exactly that many times, or
  2. Modifying the SharedPrinter.Wait() implementation to safely handle multiple calls

The current implementation of SharedPrinter.Wait() assumes it will be called exactly once per addition.

GitHub Flavored Markdown: No

Suggested change
for range projectIDs {
_ = printer.Wait()
}
// Only need to wait once for the printer to finish
_ = printer.Wait()

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

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