mirror of https://github.com/grpc/grpc-node.git
gts fix
This commit is contained in:
parent
a53bcb3c97
commit
7625c2becd
|
@ -20,7 +20,12 @@ import * as http2 from 'http2';
|
||||||
import { Duplex, Readable, Writable } from 'stream';
|
import { Duplex, Readable, Writable } from 'stream';
|
||||||
|
|
||||||
import { StatusObject } from './call-stream';
|
import { StatusObject } from './call-stream';
|
||||||
import { Status, DEFAULT_MAX_SEND_MESSAGE_LENGTH, DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH, LogVerbosity } from './constants';
|
import {
|
||||||
|
Status,
|
||||||
|
DEFAULT_MAX_SEND_MESSAGE_LENGTH,
|
||||||
|
DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH,
|
||||||
|
LogVerbosity,
|
||||||
|
} from './constants';
|
||||||
import { Deserialize, Serialize } from './make-client';
|
import { Deserialize, Serialize } from './make-client';
|
||||||
import { Metadata } from './metadata';
|
import { Metadata } from './metadata';
|
||||||
import { StreamDecoder } from './stream-decoder';
|
import { StreamDecoder } from './stream-decoder';
|
||||||
|
@ -70,7 +75,7 @@ export type ServerErrorResponse = ServerStatusResponse & Error;
|
||||||
|
|
||||||
export type ServerSurfaceCall = {
|
export type ServerSurfaceCall = {
|
||||||
cancelled: boolean;
|
cancelled: boolean;
|
||||||
readonly metadata: Metadata
|
readonly metadata: Metadata;
|
||||||
getPeer(): string;
|
getPeer(): string;
|
||||||
sendMetadata(responseMetadata: Metadata): void;
|
sendMetadata(responseMetadata: Metadata): void;
|
||||||
} & EventEmitter;
|
} & EventEmitter;
|
||||||
|
@ -458,10 +463,13 @@ export class Http2ServerCallStream<
|
||||||
stream.once('end', async () => {
|
stream.once('end', async () => {
|
||||||
try {
|
try {
|
||||||
const requestBytes = Buffer.concat(chunks, totalLength);
|
const requestBytes = Buffer.concat(chunks, totalLength);
|
||||||
if (this.maxReceiveMessageSize !== -1 && requestBytes.length > this.maxReceiveMessageSize) {
|
if (
|
||||||
|
this.maxReceiveMessageSize !== -1 &&
|
||||||
|
requestBytes.length > this.maxReceiveMessageSize
|
||||||
|
) {
|
||||||
this.sendError({
|
this.sendError({
|
||||||
code: Status.RESOURCE_EXHAUSTED,
|
code: Status.RESOURCE_EXHAUSTED,
|
||||||
details: `Received message larger than max (${requestBytes.length} vs. ${this.maxReceiveMessageSize})`
|
details: `Received message larger than max (${requestBytes.length} vs. ${this.maxReceiveMessageSize})`,
|
||||||
});
|
});
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
|
@ -532,7 +540,14 @@ export class Http2ServerCallStream<
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
trace('Request to method ' + this.handler?.path + ' ended with status code: ' + Status[statusObj.code] + ' details: ' + statusObj.details);
|
trace(
|
||||||
|
'Request to method ' +
|
||||||
|
this.handler?.path +
|
||||||
|
' ended with status code: ' +
|
||||||
|
Status[statusObj.code] +
|
||||||
|
' details: ' +
|
||||||
|
statusObj.details
|
||||||
|
);
|
||||||
|
|
||||||
clearTimeout(this.deadline);
|
clearTimeout(this.deadline);
|
||||||
|
|
||||||
|
@ -587,10 +602,13 @@ export class Http2ServerCallStream<
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.maxSendMessageSize !== -1 && chunk.length > this.maxSendMessageSize) {
|
if (
|
||||||
|
this.maxSendMessageSize !== -1 &&
|
||||||
|
chunk.length > this.maxSendMessageSize
|
||||||
|
) {
|
||||||
this.sendError({
|
this.sendError({
|
||||||
code: Status.RESOURCE_EXHAUSTED,
|
code: Status.RESOURCE_EXHAUSTED,
|
||||||
details: `Sent message larger than max (${chunk.length} vs. ${this.maxSendMessageSize})`
|
details: `Sent message larger than max (${chunk.length} vs. ${this.maxSendMessageSize})`,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -621,10 +639,13 @@ export class Http2ServerCallStream<
|
||||||
const messages = decoder.write(data);
|
const messages = decoder.write(data);
|
||||||
|
|
||||||
for (const message of messages) {
|
for (const message of messages) {
|
||||||
if (this.maxReceiveMessageSize !== -1 && message.length > this.maxReceiveMessageSize) {
|
if (
|
||||||
|
this.maxReceiveMessageSize !== -1 &&
|
||||||
|
message.length > this.maxReceiveMessageSize
|
||||||
|
) {
|
||||||
this.sendError({
|
this.sendError({
|
||||||
code: Status.RESOURCE_EXHAUSTED,
|
code: Status.RESOURCE_EXHAUSTED,
|
||||||
details: `Received message larger than max (${message.length} vs. ${this.maxReceiveMessageSize})`
|
details: `Received message larger than max (${message.length} vs. ${this.maxReceiveMessageSize})`,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,11 @@ import {
|
||||||
} from './server-call';
|
} from './server-call';
|
||||||
import { ServerCredentials } from './server-credentials';
|
import { ServerCredentials } from './server-credentials';
|
||||||
import { ChannelOptions } from './channel-options';
|
import { ChannelOptions } from './channel-options';
|
||||||
import { createResolver, ResolverListener, mapUriDefaultScheme } from './resolver';
|
import {
|
||||||
|
createResolver,
|
||||||
|
ResolverListener,
|
||||||
|
mapUriDefaultScheme,
|
||||||
|
} from './resolver';
|
||||||
import * as logging from './logging';
|
import * as logging from './logging';
|
||||||
import {
|
import {
|
||||||
SubchannelAddress,
|
SubchannelAddress,
|
||||||
|
@ -538,11 +542,20 @@ export class Server {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const path = headers[http2.constants.HTTP2_HEADER_PATH] as string;
|
const path = headers[http2.constants.HTTP2_HEADER_PATH] as string;
|
||||||
trace('Received call to method ' + path + ' at address ' + http2Server.address()?.toString());
|
trace(
|
||||||
|
'Received call to method ' +
|
||||||
|
path +
|
||||||
|
' at address ' +
|
||||||
|
http2Server.address()?.toString()
|
||||||
|
);
|
||||||
const handler = this.handlers.get(path);
|
const handler = this.handlers.get(path);
|
||||||
|
|
||||||
if (handler === undefined) {
|
if (handler === undefined) {
|
||||||
trace('No handler registered for method ' + path + '. Sending UNIMPLEMENTED status.');
|
trace(
|
||||||
|
'No handler registered for method ' +
|
||||||
|
path +
|
||||||
|
'. Sending UNIMPLEMENTED status.'
|
||||||
|
);
|
||||||
throw getUnimplementedStatusResponse(path);
|
throw getUnimplementedStatusResponse(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue