Skip to content
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

Cleanup streaming errors for block not ready #5632

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions engine/access/rpc/backend/backend_stream_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func (b *backendSubscribeBlocks) getBlock(height uint64, expectedBlockStatus flo

// validateHeight checks if the given block height is valid and available based on the expected block status.
// Expected errors during normal operation:
// - storage.ErrNotFound: block for the given block height is not available.
// - subscription.ErrBlockNotReady when unable to retrieve the block by height.
func (b *backendSubscribeBlocks) validateHeight(height uint64, expectedBlockStatus flow.BlockStatus) error {
highestHeight, err := b.blockTracker.GetHighestHeight(expectedBlockStatus)
AndriiDiachuk marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
Expand All @@ -330,7 +330,7 @@ func (b *backendSubscribeBlocks) validateHeight(height uint64, expectedBlockStat
// note: it's possible for the data to exist in the data store before the notification is
// received. this ensures a consistent view is available to all streams.
if height > highestHeight {
return fmt.Errorf("block %d is not available yet: %w", height, storage.ErrNotFound)
return fmt.Errorf("block %d is not available yet: %w", height, subscription.ErrBlockNotReady)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions engine/access/state_stream/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ func New(

// getExecutionData returns the execution data for the given block height.
// Expected errors during normal operation:
// - storage.ErrNotFound or execution_data.BlobNotFoundError: execution data for the given block height is not available.
// - subscription.ErrBlockNotReady or execution_data.BlobNotFoundError: execution data for the given block height is not available.
func (b *StateStreamBackend) getExecutionData(ctx context.Context, height uint64) (*execution_data.BlockExecutionDataEntity, error) {
highestHeight := b.ExecutionDataTracker.GetHighestHeight()
// fail early if no notification has been received for the given block height.
// note: it's possible for the data to exist in the data store before the notification is
// received. this ensures a consistent view is available to all streams.
if height > highestHeight {
return nil, fmt.Errorf("execution data for block %d is not available yet: %w", height, storage.ErrNotFound)
return nil, fmt.Errorf("execution data for block %d is not available yet: %w", height, subscription.ErrBlockNotReady)
}

execData, err := b.execDataCache.ByHeight(ctx, height)
AndriiDiachuk marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading