grpc-reflection doesn't load properly when an imported type doesn't have a package
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- node.js, typescript
Direzione di ricerca
Inizia da packages/grpc-reflection/src/implementations/reflection-v1.ts e verifica come vengono risolti i simboli referenziati quando un tipo importato non ha un package. Riproduci il caso usando examples/protos/helloworld.proto e examples/protos/nopackage.proto, quindi confronta il comportamento con packages/grpc-reflection/test/test-reflection-v1-implementation.ts. Il lavoro è completato quando reflection carica la definizione del servizio senza gli avvisi NoPackage, con un test di regressione che copra il caso.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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:
- Lingua principale
- TypeScript
- Stelle
- 4.8k
- Fork
- 716
- Merge medio
- 1g 18h
- PR unite (30g)
- 17
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di grpc/grpc-node
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 2 giorni
-
package: @grpc/grpc-js
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
grpc/grpc-node#2993 · 3 commenti · 4 reazioni ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
grpc/grpc-node#3091 · 1 reazione ·
I maintainer di solito rispondono entro 2 giorni
-
feature request
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
grpc/grpc-node#3077 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 76/100
grpc/grpc-node#3068 · 2 commenti · 1 reazione ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di grpc/grpc-node
Issue simili
-
priority: P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
prime-radiant-inc/evener#3291 ·
I maintainer di solito rispondono entro 1 giorno
-
accessibility bug revealjs
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
quarto-dev/quarto-cli#14961 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
supabase/agent-skills#614 ·
-
Content
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
RunestoneInteractive/rs#1559 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni