mirror of
https://github.com/sofastack/sofa-rpc-node.git
synced 2026-02-01 16:56:23 +00:00
fix: grpc server crashes down when receives large request body (#45)
This commit is contained in:
parent
654c25cc92
commit
e800e19372
@ -99,7 +99,7 @@ class GRpcServer extends RpcServer {
|
||||
let buf = null;
|
||||
stream.on('data', data => {
|
||||
if (buf) {
|
||||
buf = Buffer.concat([ this._buf, data ]);
|
||||
buf = Buffer.concat([ buf, data ]);
|
||||
} else {
|
||||
buf = data;
|
||||
}
|
||||
|
||||
@ -127,4 +127,14 @@ describe('test/grpc/index.test.js', () => {
|
||||
consumer.close();
|
||||
}
|
||||
});
|
||||
|
||||
it('should invoke large request body ok', async function() {
|
||||
const consumer = client.createConsumer({
|
||||
interfaceName: 'helloworld.Greeter',
|
||||
serverHost: 'http://localhost:' + port,
|
||||
});
|
||||
await consumer.ready();
|
||||
const largeStr = Buffer.alloc(100 * 1024);
|
||||
await consumer.invoke('SayHi', [{ name: largeStr.toString() }], {});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user