grpc-node icon indicating copy to clipboard operation
grpc-node copied to clipboard

grpc stream typescript type of error in `call.on('error'` is Error instead of grpc.ServiceError

Open Fabioni opened this issue 9 months ago • 1 comments

Problem description

The type of the error in

const call = client.RequestFooStream({});
call.on('error', (error) => {}

is Error. I assume it should be grpc.ServiceError which is defined as export type ServiceError = StatusObject & Error; inside your package.

Environment

  • @grpc/grpc-js: 1.13.3
  • Node v20

Fabioni avatar Apr 11 '25 14:04 Fabioni

I don't think that would be entirely correct, because the streaming call types are subtypes of the built in stream classes. That means that there may be other error events than the ServiceError ones, so Error is the most generally correct type.

murgatroid99 avatar Apr 25 '25 18:04 murgatroid99