Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

grpc-reflection doesn't load properly when an imported type doesn't have a package

Abierto
#2,934 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
node.js, typescript
Área
api, backend, testing

Línea de trabajo

Comienza con packages/grpc-reflection/src/implementations/reflection-v1.ts e inspecciona cómo se resuelven los símbolos referenciados cuando un tipo importado no tiene package. Reproduce el caso usando examples/protos/helloworld.proto y examples/protos/nopackage.proto y, después, compara el comportamiento con packages/grpc-reflection/test/test-reflection-v1-implementation.ts. El trabajo estará terminado cuando reflection cargue la definición del servicio sin las advertencias NoPackage y haya una prueba de regresión que cubra el caso.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

package: @grpc/reflection
Problem description

When imported type doesn't have a package, and it is used as a field, when I try to enable reflection, first I get these warnings:

Could not find file associated with reference NoPackage

But the gRPC service starts succesfully. However, when trying to load the service definition in Postman I get this error:

Image

Reproduction steps

I modified your reflection example to simulate the problem we have in our code. Please check here. See these 2 files:

  • examples/protos/helloworld.proto
  • examples/protos/nopackage.proto

This is what I get when I run it:

$ node ./reflection/server.js 
Debugger listening on ws://127.0.0.1:53801/5014bd58-6641-4daa-a11b-f7b03f82abcb
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Could not find file associated with reference NoPackage  <--- these are the warnings in question
Could not find file associated with reference NoPackage
(node:141961) DeprecationWarning: Calling start() is no longer necessary. It can be safely omitted.
(Use `node --trace-deprecation ...` to show where the warning was created)

And if I try to load the definition via reflection in postman, I will get the error on the screenshot above.

Environment
  • OS name, version and architecture: Debian GNU/Linux 12 (bookworm), AMD x64
  • Node version: v20.18.0
  • Node installation method: for this particular example I used npm, but in our project we use yarn
  • Package name and version: @grpc/[email protected]
Additional context

This seem related to this issue: https://github.com/grpc/grpc-node/issues/2671, but sort of in reverse. Instead of removing the dot, I need to add one.

The way I resolved it is by simply checking if there is a reference with a leading dot. See packages/grpc-reflection/src/implementations/reflection-v1.ts in the same branch:

        // if we didn't find anything then try just a FQN lookup
        if (!referencedFile) {
          referencedFile = this.symbols[ref] ?? this.symbols[`.${ref}`];
        }

I would have opened a PR with my change, but I am not sure how to test it. I tried to add a test to packages/grpc-reflection/test/test-reflection-v1-implementation.ts (and updated *.proto files to have the same setup), but regardless of whether this fix is present or not, I get the same content for reflectionService.

But if you rerun the example service with the fix, definition loads via reflection with no issues:
Image

And Postman can even generate some sample request:
Image

Lenguaje dominante
TypeScript
Estrellas
4.8k
Forks
717
Merge medio
1 d 18 h
PR fusionados (30 d)
17

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de grpc/grpc-node

Todos los issues de grpc/grpc-node

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.