-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: GrpcClient.loadProtoJSON to load protobuf.js JSON proto #985
Conversation
Codecov Report
@@ Coverage Diff @@
## master #985 +/- ##
==========================================
- Coverage 88.58% 88.55% -0.04%
==========================================
Files 43 43
Lines 7098 7123 +25
Branches 612 617 +5
==========================================
+ Hits 6288 6308 +20
- Misses 800 805 +5
Partials 10 10
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this looks pretty good to me. Should be a fairly clean fix for pack utils :)
* In rare cases users might need to deallocate all memory consumed by loaded protos. | ||
* This method will delete the proto cache content. | ||
*/ | ||
static clearProtoCache() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually... I kind of want to expose this in Pub/Sub, but that's a separate discussion. It would probably fix an issue with proto memory leaks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it must be accessible from Pub/Sub, but let's talk about memory leaks separately: I believe that with caching there should be none :)
This is the first part of the change to stop using
fs
during loading protos, replacing it withrequire()
. This was inspired by the discussion in googleapis/nodejs-pubsub#1246.Since
@grpc/proto-loader
v0.6+ supports loading protos from protobuf.js JSON representation (.fromJSON
), we can now avoid usingfs
altogether and justrequire()
the proto JSON file, and then pass it to the proto loader. This will make all the bundlers much happier.The second part of this fix will be in the generator which would need to start calling the new
.loadProtoJSON
instead of the existing.loadProto
.Note: the change to
isBrowser
invocation infallback.ts
is unrelated, it just got caught by my linter and I fixed it. It's actually a bug!