Skip to content

Make run.go easier to read#2214

Draft
dgageot wants to merge 1 commit intodocker:mainfrom
dgageot:run-easier-read
Draft

Make run.go easier to read#2214
dgageot wants to merge 1 commit intodocker:mainfrom
dgageot:run-easier-read

Conversation

@dgageot
Copy link
Member

@dgageot dgageot commented Mar 22, 2026

No description provided.

Copy link

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

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

Assessment: 🟡 NEEDS ATTENTION

This refactoring extracts profiling and recording logic into separate packages, improving code organization. However, there is one design issue in the new profiling API that should be addressed.

})
}

return func() {
Copy link

Choose a reason for hiding this comment

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

MEDIUM: Error Handling Issue

The Stop function signature returns nothing (func()), which prevents callers from detecting when profile writing fails. If memory profile creation fails (e.g., disk full, permission denied), the error is only logged via slog.Error but the caller has no way to know the profile wasn't written.

Recommendation:
Consider changing the Stop type to return an error:

type Stop func() error

Then aggregate errors from all closers:

return func() error {
    var errs []error
    for i := len(closers) - 1; i >= 0; i-- {
        if err := closers[i](); err != nil {
            errs = append(errs, err)
        }
    }
    if len(errs) > 0 {
        return fmt.Errorf("profiling cleanup errors: %v", errs)
    }
    return nil
}

This allows callers to detect and handle profiling failures appropriately.

@dgageot dgageot marked this pull request as draft March 22, 2026 12:44
Assisted-By: docker-agent
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.

1 participant