grpc-reflection doesn't load properly when an imported type doesn't have a package
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
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
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:
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.protoexamples/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:
And Postman can even generate some sample request:
- Lenguaje dominante
- TypeScript
- Estrellas
- 4.8k
- Forks
- 717
- Merge medio
- 1 d 18 h
- PR fusionados (30 d)
- 17
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de grpc/grpc-node
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 2 días
-
package: @grpc/grpc-js
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
grpc/grpc-node#2993 · 3 comentarios · 4 reacciones ·
Los mantenedores suelen responder en 2 días
-
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
grpc/grpc-node#3091 · 1 reacción ·
Los mantenedores suelen responder en 2 días
-
feature request
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
grpc/grpc-node#3077 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
Dificultad 3/5 1-2 días Aptitud para principiantes 76/100
grpc/grpc-node#3068 · 2 comentarios · 1 reacción ·
Los mantenedores suelen responder en 2 días
Todos los issues de grpc/grpc-node
Issues similares
-
Mend: dependency security vulnerability untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
opensearch-project/security-dashboards-plugin#2545 ·
Los mantenedores suelen responder en 1 día
-
Add: Dream TR SDAbiertocheck:passed streams:add
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
doctor integrity sample scans soft-deleted pages on Postgres (batch path has no deleted_at filter)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
SocialGouv/egapro#4672 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
area:agents area:tui bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
anthropics/claude-code#98358 ·
Los mantenedores suelen responder en 1 día