Skip to content

flaky test fix#2940

Merged
pompon0 merged 4 commits intomainfrom
gprusak-after-cancel
Feb 20, 2026
Merged

flaky test fix#2940
pompon0 merged 4 commits intomainfrom
gprusak-after-cancel

Conversation

@pompon0
Copy link
Contributor

@pompon0 pompon0 commented Feb 20, 2026

Added more precise handling of background tasks in tests which are allowed to fail during test cleanup.

@github-actions
Copy link

github-actions bot commented Feb 20, 2026

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedFeb 20, 2026, 6:47 PM

return fmt.Errorf("peerTransport.dial(): %w", err)
}
s.SpawnBg(func() error { return tcpConn.Run(ctx) })
s.SpawnBg(func() error { return utils.IgnoreCancel(tcpConn.Run(ctx)) })
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fyi, this one is intentional, because peer is not expected to end the connection first.

@codecov
Copy link

codecov bot commented Feb 20, 2026

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 68.73%. Comparing base (d1885eb) to head (ca903a0).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
sei-tendermint/libs/utils/testonly.go 75.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #2940       +/-   ##
===========================================
+ Coverage   57.76%   68.73%   +10.97%     
===========================================
  Files        2111       35     -2076     
  Lines      174240     2930   -171310     
===========================================
- Hits       100653     2014    -98639     
+ Misses      64631      743    -63888     
+ Partials     8956      173     -8783     
Flag Coverage Δ
sei-chain 68.79% <80.00%> (+11.05%) ⬆️
sei-db 68.42% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sei-tendermint/libs/utils/tcp/tcp.go 74.05% <100.00%> (-0.48%) ⬇️
sei-tendermint/libs/utils/testonly.go 70.58% <75.00%> (+0.18%) ⬆️

... and 2079 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.


func (c Conn) Run(ctx context.Context) error {
return utils.IgnoreCancel(scope.Run(ctx, func(ctx context.Context, s scope.Scope) error {
return scope.Run(ctx, func(ctx context.Context, s scope.Scope) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we removing this IgnoreCancel?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

to handle the error in a more robust way at the call site

// For example - if you have a tcp connection, then during cleanup one end will disconnect faster than the other,
// causing a race condition between context cancellation and disconnection error.
func IgnoreAfterCancel(ctx context.Context, err error) error {
if ctx.Err() != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

// IgnoreAfterCancel silently drops the error if the context is already canceled.

Does it? It drops any old error in context. There could be different types of error here.

I am sorry I sound like a broken record: These utility functions are anti-pattern: they add more LoC than they save; and more cognitive load than it should take to read simple go code.

Copy link
Contributor Author

@pompon0 pompon0 Feb 20, 2026

Choose a reason for hiding this comment

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

Does it? It drops any old error in context. There could be different types of error here.

True, context may contain various errors as well, I use word "canceled" to not say "context is done" or "context.Done() channel is closed" because it sounds weird and I've never heard anyone saying this. Also given that context is propagated to arbitrary subroutines, allowing to terminate/cancell/close done channel of context with an error different Canceled was a design mistake, because it makes literally almost ALL of golang code need to handle arbitrary errors they are not even aware of.

These utility functions are anti-pattern: they add more LoC than they save; and more cognitive load than it should take to read simple go code.

Well, that's like your opinion, man. I find your select clauses hardly readable, if you really would like to know.

@pompon0 pompon0 enabled auto-merge (squash) February 20, 2026 18:47
@pompon0 pompon0 merged commit 16884af into main Feb 20, 2026
35 checks passed
@pompon0 pompon0 deleted the gprusak-after-cancel branch February 20, 2026 19:01
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.

4 participants