Skip to content

Commit

Permalink
resolve: to prevent goroutine leak, make certain to cancel the contex…
Browse files Browse the repository at this point in the history
…t involved in running the source used to resolve start block.
  • Loading branch information
colindickson committed Jan 12, 2025
1 parent e1f1141 commit 9e6c413
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pipeline/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,10 @@ func resolveStartBlockNum(ctx context.Context, req *pbsubstreamsrpc.Request, res
return 0, "", nil, connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("StartCursor is invalid: LIB %d greater than Block %d", cursor.LIB.Num(), cursor.Block.Num()))
}

reorgJunctionBlock, head, err := resolveCursor(ctx, cursor)
resolveCtx, resolveCancel := context.WithCancel(ctx)
defer resolveCancel()

reorgJunctionBlock, head, err := resolveCursor(resolveCtx, cursor)
if err != nil {
return 0, "", nil, connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("cannot resolve StartCursor %q: %s", cursor, err.Error()))
}
Expand Down

0 comments on commit 9e6c413

Please sign in to comment.