fix: grpc server crashes down when receives large request body (#45)

This commit is contained in:
RabbitSion 2019-05-06 10:50:35 +08:00 committed by zōng yǔ
parent 654c25cc92
commit e800e19372
2 changed files with 11 additions and 1 deletions

View File

@ -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;
}

View File

@ -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() }], {});
});
});