mirror of https://github.com/grpc/grpc-node.git
grpc-js: Update gts and apply fixes
This commit is contained in:
parent
a5e12074e2
commit
fc032c0226
|
|
@ -26,7 +26,7 @@
|
|||
"@types/semver": "^6.0.1",
|
||||
"clang-format": "^1.0.55",
|
||||
"execa": "^2.0.3",
|
||||
"gts": "^1.0.0",
|
||||
"gts": "^1.1.0",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-mocha": "^6.0.0",
|
||||
"lodash": "^4.17.4",
|
||||
|
|
|
|||
|
|
@ -348,7 +348,11 @@ export class Http2CallStream extends Duplex implements Call {
|
|||
* call. This should ensure that this endCall happens sooner than the one
|
||||
* in the stream.on('close', ...) handler. */
|
||||
stream.session.socket.on('close', () => {
|
||||
this.endCall({code: Status.UNAVAILABLE, details: 'Connection dropped', metadata: new Metadata()});
|
||||
this.endCall({
|
||||
code: Status.UNAVAILABLE,
|
||||
details: 'Connection dropped',
|
||||
metadata: new Metadata(),
|
||||
});
|
||||
});
|
||||
if (!this.pendingRead) {
|
||||
stream.pause();
|
||||
|
|
|
|||
|
|
@ -38,10 +38,19 @@ import {
|
|||
Serialize,
|
||||
} from './make-client';
|
||||
import { Metadata } from './metadata';
|
||||
import { Server, UntypedHandleCall, UntypedServiceImplementation } from './server';
|
||||
import {
|
||||
Server,
|
||||
UntypedHandleCall,
|
||||
UntypedServiceImplementation,
|
||||
} from './server';
|
||||
import { KeyCertPair, ServerCredentials } from './server-credentials';
|
||||
import { StatusBuilder } from './status-builder';
|
||||
import { ServerUnaryCall, ServerReadableStream, ServerWritableStream, ServerDuplexStream } from './server-call';
|
||||
import {
|
||||
ServerUnaryCall,
|
||||
ServerReadableStream,
|
||||
ServerWritableStream,
|
||||
ServerDuplexStream,
|
||||
} from './server-call';
|
||||
|
||||
const supportedNodeVersions = require('../../package.json').engines.node;
|
||||
if (!semver.satisfies(process.version, supportedNodeVersions)) {
|
||||
|
|
@ -219,7 +228,7 @@ export {
|
|||
ServerWritableStream,
|
||||
ServerDuplexStream,
|
||||
UntypedHandleCall,
|
||||
UntypedServiceImplementation
|
||||
UntypedServiceImplementation,
|
||||
};
|
||||
|
||||
/* tslint:disable:no-any */
|
||||
|
|
|
|||
|
|
@ -76,9 +76,11 @@ export type ServerReadableStream<
|
|||
export type ServerWritableStream<
|
||||
RequestType,
|
||||
ResponseType
|
||||
> = ServerSurfaceCall & ObjectWritable<ResponseType> & { request: RequestType | null };
|
||||
> = ServerSurfaceCall &
|
||||
ObjectWritable<ResponseType> & { request: RequestType | null };
|
||||
export type ServerDuplexStream<RequestType, ResponseType> = ServerSurfaceCall &
|
||||
ObjectReadable<RequestType> & ObjectWritable<ResponseType>;
|
||||
ObjectReadable<RequestType> &
|
||||
ObjectWritable<ResponseType>;
|
||||
|
||||
export class ServerUnaryCallImpl<RequestType, ResponseType> extends EventEmitter
|
||||
implements ServerUnaryCall<RequestType, ResponseType> {
|
||||
|
|
@ -497,15 +499,18 @@ export class Http2ServerCallStream<
|
|||
sendError(error: ServerErrorResponse | ServerStatusResponse) {
|
||||
const status: StatusObject = {
|
||||
code: Status.UNKNOWN,
|
||||
details: ('message' in error)
|
||||
? error.message
|
||||
: 'Unknown Error',
|
||||
metadata: ('metadata' in error && error.metadata !== undefined)
|
||||
details: 'message' in error ? error.message : 'Unknown Error',
|
||||
metadata:
|
||||
'metadata' in error && error.metadata !== undefined
|
||||
? error.metadata
|
||||
: new Metadata(),
|
||||
};
|
||||
|
||||
if ('code' in error && typeof error.code === 'number' && Number.isInteger(error.code)) {
|
||||
if (
|
||||
'code' in error &&
|
||||
typeof error.code === 'number' &&
|
||||
Number.isInteger(error.code)
|
||||
) {
|
||||
status.code = error.code;
|
||||
|
||||
if ('details' in error && typeof error.details === 'string') {
|
||||
|
|
|
|||
|
|
@ -102,7 +102,10 @@ export class Server {
|
|||
throw new Error('Not implemented. Use addService() instead');
|
||||
}
|
||||
|
||||
addService(service: ServiceDefinition, implementation: UntypedServiceImplementation): void {
|
||||
addService(
|
||||
service: ServiceDefinition,
|
||||
implementation: UntypedServiceImplementation
|
||||
): void {
|
||||
if (this.started === true) {
|
||||
throw new Error("Can't add a service to a started server.");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue