Skip to content

Log tier1 client disconnects as Canceled, not Unknown#832

Open
sduchesneau wants to merge 1 commit into
developfrom
fix-context-canceled-log-severity
Open

Log tier1 client disconnects as Canceled, not Unknown#832
sduchesneau wants to merge 1 commit into
developfrom
fix-context-canceled-log-severity

Conversation

@sduchesneau

Copy link
Copy Markdown
Contributor

Problem

Client disconnects on a tier1 Blocks stream (context canceled) are logged noisily at WARNING and ERROR:

severity: WARNING  message: "Blocks request completed with error"  error: "canceled: context canceled"
severity: ERROR    message: "finished streaming call with code Unknown"  grpc.code: "Unknown"  error: "canceled: context canceled"

Root cause

toGrpcTier1Error (service/error.go) returns a connect error for the context-canceled case:

return connect.NewError(connect.CodeCanceled, err)

Every other branch in that function returns a gRPC status.Error(codes.X, ...). The caller in service_grpc.go then does status.Code(grpcErr) — and status.Code() on a connect error (not a gRPC status) returns codes.Unknown. So:

  • service_grpc.go falls through to defaultlogger.Warn("Blocks request completed with error") instead of the codes.Canceled case (Debug).
  • The gRPC logging middleware sees code Unknown → logs the finished call at ERROR (grpc_zap maps Unknown→Error, Canceled→Info).

Fix

Return a gRPC status error for the canceled branch, consistent with the rest of the function:

return status.Error(codes.Canceled, err.Error())

Now status.Code() resolves to codes.Canceled: service_grpc.go logs at Debug ("Blocks request canceled by user"), and the middleware logs the call at Info. The connect path (toConnectError) already handled this correctly and is unchanged.

🤖 Generated with Claude Code

toGrpcTier1Error returned a connect error for the context-canceled case,
while every other branch returns a gRPC status error. status.Code() on a
connect error resolves to Unknown, so client disconnects were logged as a
WARN ("Blocks request completed with error") and the gRPC middleware
reported the call at ERROR with code Unknown. Return codes.Canceled so
the disconnect is logged quietly at Debug/Info.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sduchesneau

Copy link
Copy Markdown
Contributor Author

🔍 Vulnerabilities of ghcr.io/streamingfast/substreams:0bc218a

📦 Image Reference ghcr.io/streamingfast/substreams:0bc218a
digestsha256:12fb2903c4ae827cf35c81601b8d3a45147d4851b08e69f9f2889276e23735fb
vulnerabilitiescritical: 0 high: 0 medium: 0 low: 0
platformlinux/amd64
size109 MB
packages353
📦 Base Image ubuntu:24.04
also known as
  • noble
  • noble-20260610
digestsha256:52df9b1ee71626e0088f7d400d5c6b5f7bb916f8f0c82b474289a4ece6cf3faf
vulnerabilitiescritical: 0 high: 0 medium: 14 low: 5

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.

2 participants