Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 276
refactor: halt at app failure#2268
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
5e77da5d4d6fc31f75ad7341a37bc6a785f900fb06e5dcf6b3db6aca5cdd35fFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -82,7 +82,7 @@ func TestAggregationLoop_Normal_BasicInterval(t *testing.T) { | ||
| wg.Add(1) | ||
| go func() { | ||
| defer wg.Done() | ||
| m.AggregationLoop(ctx) | ||
| m.AggregationLoop(ctx, make(chan<- error)) | ||
| m.logger.Info("AggregationLoop exited") | ||
| }() | ||
| @@ -118,12 +118,10 @@ func TestAggregationLoop_Normal_BasicInterval(t *testing.T) { | ||
| // TestAggregationLoop_Normal_PublishBlockError verifies that the aggregation loop handles errors from publishBlock gracefully. | ||
| func TestAggregationLoop_Normal_PublishBlockError(t *testing.T) { | ||
| t.Parallel() | ||
| assert := assert.New(t) | ||
| require := require.New(t) | ||
| blockTime := 50 * time.Millisecond | ||
| waitTime := blockTime*4 + blockTime/2 | ||
| tolerance := blockTime / 2 | ||
| mockStore := mocks.NewStore(t) | ||
| mockStore.On("Height", mock.Anything).Return(uint64(1), nil).Maybe() | ||
| @@ -185,10 +183,12 @@ func TestAggregationLoop_Normal_PublishBlockError(t *testing.T) { | ||
| ctx, cancel := context.WithCancel(context.Background()) | ||
| var wg sync.WaitGroup | ||
| errCh := make(chan error, 1) | ||
| wg.Add(1) | ||
| go func() { | ||
| defer wg.Done() | ||
| m.AggregationLoop(ctx) | ||
| m.AggregationLoop(ctx, errCh) | ||
| m.logger.Info("AggregationLoop exited") | ||
| }() | ||
| @@ -201,12 +201,7 @@ func TestAggregationLoop_Normal_PublishBlockError(t *testing.T) { | ||
| defer publishLock.Unlock() | ||
| calls := publishCalls.Load() | ||
| assert.GreaterOrEqualf(calls, int64(4), "publishBlock should have been called multiple times (around 4), but was called %d times", calls) | ||
| assert.LessOrEqualf(calls, int64(5), "publishBlock should have been called multiple times (around 4-5), but was called %d times", calls) | ||
| require.GreaterOrEqual(len(publishTimes), 3, "Need at least 3 timestamps to check intervals after error") | ||
| for i := 2; i < len(publishTimes); i++ { | ||
| interval := publishTimes[i].Sub(publishTimes[i-1]) | ||
| WithinDuration(t, blockTime, interval, tolerance) | ||
| } | ||
| require.Equal(calls, int64(1)) | ||
| require.ErrorContains(<-errCh, expectedErr.Error()) | ||
| require.Equal(len(publishTimes), 1, "Expected only one publish time after error") | ||
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The relevant publishing issues that shouldn't halt have been changed to warning logs. | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Loop exits on single publish error
Returning the error here causes the entire lazy loop to stop after a single failed
publishBlock.If the goal is “halt at app failure” but still tolerate transient DA/network errors, consider distinguishing between fatal and retryable errors, e.g.: