Skip to content

JSON parse error - Unexpected token 'N', "No connect"... is not valid JSON #13

Open
@mirkobertone

Description

@mirkobertone

Hi!
I have an architecture with an apigateway(grpc client) and a microservice(grpc server) .
When the grpc server is down, the GrpcToHttpInterceptor in controller catch this error:

{
  code: 14,
  details: "No connection established. Last error: connect ECONNREFUSED 0.0.0.0:50051 (2024-04-09T08:38:21.111Z)",
  metadata: {
    internalRepr: {
    },
    options: {
    },
  },
}

The JSON.parse(err.details) brake in this case. Is it possible the if statement isn't checking in the right way?
I've also check with debug and I attach a screen

image

image

Here my controller in apigateway and interceptor


@UseInterceptors(GrpcToHttpInterceptor)
@Controller('/api/actors')
export class ActorController {
  constructor(
    private readonly actorsService: ApiActorService,
    private readonly logger: WinstonLoggerService,
  ) {}

  @Post()
  @ApiOperation({ summary: 'Create an actor' })
  create(@Body() actor: CreateActorRequest, @GetTraceId() traceID: string): Promise<ActorResponse> {
    return this.actorsService.create(actor, { traceID });
  }

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions