Error: grpc-js doesn't work with FlatBuffer message (message.copy is not a function)
See original GitHub issueProblem description
gprc (native node module) works with FlatBuffers message but pure js version seems to be buggy with it.
Reproduction steps
- Write a .fbs schema file with RPC service, generate JS, TS definitions
- In JS code, create a message using FlatBuffers builder, example:
const server = new PAuthClient(ServerURL, ServerCertificate)
const builder = new flatbuffers.Builder() // create message
const email = builder.createString(this.email) // add fields to message
const password = builder.createString(this.password) // add fields to message
const service = builder.createString('___')
const root = PAuthRequest.createPAuthRequest(builder, email, password, service)
builder.finish(root)
const buffer = PAuthRequest.getRootAsPAuthRequest(new flatbuffers.ByteBuffer(builder.asUint8Array()))
// below code works with grpc native, but with grpc-js, errors printed:
// INTERNAL: message.copy is not a function
server.Authenticate(buffer, (err, response) => {
})
Environment
- OS name, version and architecture: Ubuntu 20.04 amd64
- Node version: v12.13.0
- Node installation method: nvm
- Package name and version: grpc-js - 1.5.10
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Node grpc client error: TypeError: _d.substring is not a function
I have encountered strange issue and I am unable to make a call to my grpc server from node. I am using: "@grpc/grpc-js":...
Read more >grpc/grpc - Gitter
Hi, everybody. I've been struggling with passing a JSON with Message values back and forth between systems. message Result { struct/value/any? variables =...
Read more >FlatBuffers: Tutorial - Google
This tutorial provides a basic example of how to work with FlatBuffers. We will step through a simple example application, which shows you...
Read more >Protocol Buffers Crash Course - YouTube
hard to use with JSON based application ( Javascript /browser) protoc compiler protoc --js_out=import_style=commonjs,binary:. employees.proto ...
Read more >Custom encoding: Go implementation in net/rpc vs grpc and ...
And the fact that Flatbuffers doesn't need to recreate the entire ... Helper function to deal with writing and parsing header for the ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think this is likely to be an error in the code generator. The object that ends up being
message
is the output of aserialize
function, which is a function signature that returns aBuffer
in both libraries. Since theBuffer
class has acopy
method, I can only assume that some other object made its way into that code path, and since theserialize
function is provided by the code generator, that’s where the problem probably is.My guess is that, since neither library calls every method of the
Buffer
class, the FlatBuffer code generator was able to get away with providing some other object that happens to implement the subset of theBuffer
API that thegrpc
library uses. But that is just coincidental compatibility.Yep, I should try upgrading to new FlatBuffers since I saw this line in its latest release: “Overhaul of TypeScript support.” Thanks !
Can be closed for now.