Merge branch 'master' into grpc-js_disconnect_status

This commit is contained in:
murgatroid99 2019-09-24 12:11:03 -07:00
commit adf7b08096
26 changed files with 305 additions and 134 deletions

23
MAINTAINERS.md Normal file
View File

@ -0,0 +1,23 @@
This page lists all active maintainers of this repository. If you were a
maintainer and would like to add your name to the Emeritus list, please send us a
PR.
See [GOVERNANCE.md](https://github.com/grpc/grpc-community/blob/master/governance.md)
for governance guidelines and how to become a maintainer.
See [CONTRIBUTING.md](https://github.com/grpc/grpc-community/blob/master/CONTRIBUTING.md)
for general contribution guidelines.
## Maintainers (in alphabetical order)
- [jiangtaoli2016](https://github.com/jiangtaoli2016), Google Inc.
- [jtattermusch](https://github.com/jtattermusch), Google Inc.
- [murgatroid99](https://github.com/murgatroid99), Google Inc.
- [nicolasnoble](https://github.com/nicolasnoble), Google Inc.
- [ofrobots](https://github.com/ofrobots), Google Inc.
- [srini100](https://github.com/srini100), Google Inc.
- [WeiranFang](https://github.com/WeiranFang), Google Inc.
- [wenbozhu](https://github.com/wenbozhu), Google Inc.
## Emeritus Maintainers (in alphabetical order)
- [kjin](https://github.com/kjin), Google Inc.
- [matt-kwong](https://github.com/matt-kwong), Google Inc.

View File

@ -42,7 +42,7 @@
"through2": "^2.0.3",
"ts-node": "^8.1.0",
"tslint": "^5.5.0",
"typescript": "~3.3.3333",
"typescript": "^3.5.3",
"xml2js": "^0.4.19"
},
"contributors": [

View File

@ -0,0 +1,60 @@
# grpc-health-check
Health check client and service for use with gRPC-node.
## Background
This package exports both a client and server that adhere to the [gRPC Health Checking Protocol](https://github.com/grpc/grpc/blob/master/doc/health-checking.md).
By using this package, clients and servers can rely on common proto and service definitions. This means:
- Clients can use the generated stubs to health check _any_ server that adheres to the protocol.
- Servers do not reimplement common logic for publishing health statuses.
## Installation
Use the package manager [npm](https://www.npmjs.com/get-npm) to install `grpc-health-check`.
```bash
npm install grpc-health-check
```
## Usage
### Server
Any gRPC-node server can use `grpc-health-check` to adhere to the gRPC Health Checking Protocol.
The following shows how this package can be added to a pre-existing gRPC server.
```javascript 1.8
// Import package
let health = require('grpc-health-check');
// Define service status map. Key is the service name, value is the corresponding status.
// By convention, the empty string "" key represents that status of the entire server.
const statusMap = {
"ServiceFoo": proto.grpc.health.v1.HealthCheckResponse.ServingStatus.SERVING,
"ServiceBar": proto.grpc.health.v1.HealthCheckResponse.ServingStatus.NOT_SERVING,
"": proto.grpc.health.v1.HealthCheckResponse.ServingStatus.NOT_SERVING,
};
// Construct the service implementation
let healthImpl = new health.Implementation(statusMap);
// Add the service and implementation to your pre-existing gRPC-node server
server.addService(health.service, healthImpl);
```
Congrats! Your server now allows any client to run a health check against it.
### Client
Any gRPC-node client can use `grpc-health-check` to run health checks against other servers that follow the protocol.
## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
## License
[Apache License 2.0](https://choosealicense.com/licenses/apache-2.0/)

View File

@ -1,8 +1,8 @@
{
"name": "@grpc/health-check",
"version": "1.8.0-dev",
"name": "grpc-health-check",
"version": "1.7.1",
"author": "Google Inc.",
"description": "Health check service for use with gRPC",
"description": "Health check client and service for use with gRPC-node",
"repository": {
"type": "git",
"url": "https://github.com/grpc/grpc-node.git"
@ -22,6 +22,7 @@
},
"files": [
"LICENSE",
"README.md",
"health.js",
"v1"
],

View File

@ -1,6 +1,6 @@
{
"name": "@grpc/grpc-js",
"version": "0.5.0",
"version": "0.5.4",
"description": "gRPC Library for Node - pure JS implementation",
"homepage": "https://grpc.io/",
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",
@ -16,13 +16,26 @@
"license": "Apache-2.0",
"devDependencies": {
"@grpc/proto-loader": "^0.5.0",
"@types/gulp": "^4.0.6",
"@types/gulp-mocha": "0.0.32",
"@types/lodash": "^4.14.108",
"@types/mocha": "^5.2.6",
"@types/node": "^12.7.5",
"@types/ncp": "^2.0.1",
"@types/node": "^12.7.5",
"@types/pify": "^3.0.2",
"@types/semver": "^6.0.1",
"clang-format": "^1.0.55",
"gts": "^1.0.0",
"execa": "^2.0.3",
"gts": "^1.1.0",
"gulp": "^4.0.2",
"gulp-mocha": "^6.0.0",
"lodash": "^4.17.4",
"typescript": "~3.5.1"
"mocha-jenkins-reporter": "^0.4.1",
"ncp": "^2.0.0",
"pify": "^4.0.1",
"ts-node": "^8.3.0",
"typescript": "^3.5.3"
},
"contributors": [
{
@ -43,7 +56,7 @@
"posttest": "npm run check"
},
"dependencies": {
"semver": "^6.0.0"
"semver": "^6.2.0"
},
"files": [
"build/src/*.{js,d.ts}",

View File

@ -259,24 +259,24 @@ export class Http2CallStream extends Duplex implements Call {
subchannel.addDisconnectListener(this.disconnectListener);
subchannel.callRef();
stream.on('response', (headers, flags) => {
switch (headers[HTTP2_HEADER_STATUS]) {
switch (headers[':status']) {
// TODO(murgatroid99): handle 100 and 101
case '400':
case 400:
this.mappedStatusCode = Status.INTERNAL;
break;
case '401':
case 401:
this.mappedStatusCode = Status.UNAUTHENTICATED;
break;
case '403':
case 403:
this.mappedStatusCode = Status.PERMISSION_DENIED;
break;
case '404':
case 404:
this.mappedStatusCode = Status.UNIMPLEMENTED;
break;
case '429':
case '502':
case '503':
case '504':
case 429:
case 502:
case 503:
case 504:
this.mappedStatusCode = Status.UNAVAILABLE;
break;
default:

View File

@ -143,11 +143,6 @@ export class Client {
);
}
});
call.on('end', () => {
if (responseMessage == null) {
call.cancelWithStatus(Status.INTERNAL, 'Not enough responses received');
}
});
call.on('status', (status: StatusObject) => {
/* We assume that call emits status after it emits end, and that it
* accounts for any cancelWithStatus calls up until it emits status.

View File

@ -38,9 +38,19 @@ import {
Serialize,
} from './make-client';
import { Metadata } from './metadata';
import { Server } 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';
const supportedNodeVersions = require('../../package.json').engines.node;
if (!semver.satisfies(process.version, supportedNodeVersions)) {
@ -213,6 +223,12 @@ export {
CallOptions,
StatusObject,
ServiceError,
ServerUnaryCall,
ServerReadableStream,
ServerWritableStream,
ServerDuplexStream,
UntypedHandleCall,
UntypedServiceImplementation,
};
/* tslint:disable:no-any */

View File

@ -251,24 +251,29 @@ export class Metadata {
const values = headers[key];
if (isBinaryKey(key)) {
if (Array.isArray(values)) {
values.forEach(value => {
result.add(key, Buffer.from(value, 'base64'));
});
} else if (values !== undefined) {
values.split(',').forEach(v => {
result.add(key, Buffer.from(v.trim(), 'base64'));
});
}
} else {
if (Array.isArray(values)) {
values.forEach(value => {
result.add(key, value);
});
} else if (values !== undefined) {
values.split(',').forEach(v => result.add(key, v.trim()));
try {
if (isBinaryKey(key)) {
if (Array.isArray(values)) {
values.forEach(value => {
result.add(key, Buffer.from(value, 'base64'));
});
} else if (values !== undefined) {
values.split(',').forEach(v => {
result.add(key, Buffer.from(v.trim(), 'base64'));
});
}
} else {
if (Array.isArray(values)) {
values.forEach(value => {
result.add(key, value);
});
} else if (values !== undefined) {
values.split(',').forEach(v => result.add(key, v.trim()));
}
}
} catch (error) {
error.message = `Failed to add metadata entry ${key}: ${values}. ${error.message}`;
process.emitWarning(error);
}
});
return result;

View File

@ -19,12 +19,12 @@ import { EventEmitter } from 'events';
import * as http2 from 'http2';
import { Duplex, Readable, Writable } from 'stream';
import { ServiceError } from './call';
import { StatusObject } from './call-stream';
import { Status } from './constants';
import { Deserialize, Serialize } from './make-client';
import { Metadata } from './metadata';
import { StreamDecoder } from './stream-decoder';
import { ObjectReadable, ObjectWritable } from './object-stream';
interface DeadlineUnitIndexSignature {
[name: string]: number;
@ -56,6 +56,10 @@ const defaultResponseOptions = {
waitForTrailers: true,
} as http2.ServerStreamResponseOptions;
export type ServerStatusResponse = Partial<StatusObject>;
export type ServerErrorResponse = ServerStatusResponse & Error;
export type ServerSurfaceCall = {
cancelled: boolean;
getPeer(): string;
@ -68,13 +72,15 @@ export type ServerUnaryCall<RequestType, ResponseType> = ServerSurfaceCall & {
export type ServerReadableStream<
RequestType,
ResponseType
> = ServerSurfaceCall & Readable;
> = ServerSurfaceCall & ObjectReadable<RequestType>;
export type ServerWritableStream<
RequestType,
ResponseType
> = ServerSurfaceCall & Writable & { request: RequestType | null };
> = ServerSurfaceCall &
ObjectWritable<ResponseType> & { request: RequestType | null };
export type ServerDuplexStream<RequestType, ResponseType> = ServerSurfaceCall &
Duplex;
ObjectReadable<RequestType> &
ObjectWritable<ResponseType>;
export class ServerUnaryCallImpl<RequestType, ResponseType> extends EventEmitter
implements ServerUnaryCall<RequestType, ResponseType> {
@ -152,7 +158,7 @@ export class ServerWritableStreamImpl<RequestType, ResponseType>
this.call.setupSurfaceCall(this);
this.on('error', err => {
this.call.sendError(err as ServiceError);
this.call.sendError(err);
this.end();
});
}
@ -223,7 +229,7 @@ export class ServerDuplexStreamImpl<RequestType, ResponseType> extends Duplex
this.call.setupReadable(this);
this.on('error', err => {
this.call.sendError(err as ServiceError);
this.call.sendError(err);
this.end();
});
}
@ -247,7 +253,7 @@ ServerDuplexStreamImpl.prototype.end = ServerWritableStreamImpl.prototype.end;
// Unary response callback signature.
export type sendUnaryData<ResponseType> = (
error: ServiceError | null,
error: ServerErrorResponse | ServerStatusResponse | null,
value: ResponseType | null,
trailer?: Metadata,
flags?: number
@ -339,7 +345,7 @@ export class Http2ServerCallStream<
) {
super();
this.stream.once('error', (err: ServiceError) => {
this.stream.once('error', (err: ServerErrorResponse) => {
err.code = Status.INTERNAL;
this.sendError(err);
});
@ -379,7 +385,7 @@ export class Http2ServerCallStream<
const match = timeoutHeader[0].toString().match(DEADLINE_REGEX);
if (match === null) {
const err = new Error('Invalid deadline') as ServiceError;
const err = new Error('Invalid deadline') as ServerErrorResponse;
err.code = Status.OUT_OF_RANGE;
this.sendError(err);
return;
@ -439,7 +445,7 @@ export class Http2ServerCallStream<
}
async sendUnaryMessage(
err: ServiceError | null,
err: ServerErrorResponse | ServerStatusResponse | null,
value: ResponseType | null,
metadata?: Metadata,
flags?: number
@ -490,22 +496,25 @@ export class Http2ServerCallStream<
}
}
sendError(error: ServiceError) {
sendError(error: ServerErrorResponse | ServerStatusResponse) {
const status: StatusObject = {
code: Status.UNKNOWN,
details: error.hasOwnProperty('message')
? error.message
: 'Unknown Error',
metadata: error.hasOwnProperty('metadata')
? error.metadata
: new Metadata(),
details: 'message' in error ? error.message : 'Unknown Error',
metadata:
'metadata' in error && error.metadata !== undefined
? error.metadata
: new Metadata(),
};
if (error.hasOwnProperty('code') && Number.isInteger(error.code)) {
if (
'code' in error &&
typeof error.code === 'number' &&
Number.isInteger(error.code)
) {
status.code = error.code;
if (error.hasOwnProperty('details')) {
status.details = error.details;
if ('details' in error && typeof error.details === 'string') {
status.details = error.details!;
}
}
@ -637,7 +646,7 @@ export class Http2ServerCallStream<
type UntypedServerCall = Http2ServerCallStream<any, any>;
function handleExpiredDeadline(call: UntypedServerCall) {
const err = new Error('Deadline exceeded') as ServiceError;
const err = new Error('Deadline exceeded') as ServerErrorResponse;
err.code = Status.DEADLINE_EXCEEDED;
call.sendError(err);

View File

@ -41,6 +41,8 @@ import {
ServerWritableStream,
ServerWritableStreamImpl,
UnaryHandler,
ServerErrorResponse,
ServerStatusResponse,
} from './server-call';
import { ServerCredentials } from './server-credentials';
@ -57,9 +59,9 @@ type UntypedUnaryHandler = UnaryHandler<any, any>;
type UntypedClientStreamingHandler = ClientStreamingHandler<any, any>;
type UntypedServerStreamingHandler = ServerStreamingHandler<any, any>;
type UntypedBidiStreamingHandler = BidiStreamingHandler<any, any>;
type UntypedHandleCall = HandleCall<any, any>;
export type UntypedHandleCall = HandleCall<any, any>;
type UntypedHandler = Handler<any, any>;
interface UntypedServiceImplementation {
export interface UntypedServiceImplementation {
[name: string]: UntypedHandleCall;
}
@ -100,7 +102,10 @@ export class Server {
throw new Error('Not implemented. Use addService() instead');
}
addService(service: ServiceDefinition, implementation: object): void {
addService(
service: ServiceDefinition,
implementation: UntypedServiceImplementation
): void {
if (this.started === true) {
throw new Error("Can't add a service to a started server.");
}
@ -120,8 +125,6 @@ export class Server {
throw new Error('Cannot add an empty service to a server');
}
const implMap: UntypedServiceImplementation = implementation as UntypedServiceImplementation;
serviceKeys.forEach(name => {
const attrs = service[name];
let methodType: HandlerType;
@ -140,11 +143,11 @@ export class Server {
}
}
let implFn = implMap[name];
let implFn = implementation[name];
let impl;
if (implFn === undefined && typeof attrs.originalName === 'string') {
implFn = implMap[attrs.originalName];
implFn = implementation[attrs.originalName];
}
if (implFn !== undefined) {
@ -414,7 +417,7 @@ async function handleUnary<RequestType, ResponseType>(
handler.func(
emitter,
(
err: ServiceError | null,
err: ServerErrorResponse | ServerStatusResponse | null,
value: ResponseType | null,
trailer?: Metadata,
flags?: number
@ -436,7 +439,7 @@ function handleClientStreaming<RequestType, ResponseType>(
);
function respond(
err: ServiceError | null,
err: ServerErrorResponse | ServerStatusResponse | null,
value: ResponseType | null,
trailer?: Metadata,
flags?: number

View File

@ -86,7 +86,7 @@ describe('Server', () => {
});
});
it('throws if bind is called after the server is started', () => {
it('throws if bind is called after the server is started', done => {
const server = new Server();
server.bindAsync(
@ -102,6 +102,7 @@ describe('Server', () => {
noop
);
}, /server is already started/);
server.tryShutdown(done);
}
);
});
@ -243,7 +244,7 @@ describe('Server', () => {
const mathClient = (loadProtoFile(mathProtoFile).math as any).Math;
const mathServiceAttrs = mathClient.service;
beforeEach(done => {
before(done => {
server = new Server();
server.addService(mathServiceAttrs, {});
server.bindAsync(
@ -261,6 +262,11 @@ describe('Server', () => {
);
});
after(done => {
client.close();
server.tryShutdown(done);
});
it('should respond to a unary call with UNIMPLEMENTED', done => {
client.div(
{ divisor: 4, dividend: 3 },

View File

@ -28,7 +28,7 @@ The `--build-from-source` option will work even when installing another package
The official electron documentation recommends to [build all of your native packages from source](https://electronjs.org/docs/tutorial/using-native-node-modules#modules-that-rely-on-node-pre-gyp). While the reasons behind this are technically good - many native extensions won't be packaged to work properly with electron - the gRPC source code is fairly difficult to build from source due to its complex nature, and we're also providing working electron pre-built binaries. Therefore, we recommend that you do not follow this model for using gRPC with electron. Also, for the same reason, `electron-rebuild` will always build from source. We advise you to not use this tool if you are depending on gRPC. Please note that there's not just one way to get native extensions running in electron, and that there's never any silver bullet for anything. The following instructions try to cater about some of the most generic ways, but different edge cases might require different methodologies.
The best to get gRPC to work with electron is to do this, possibly in your `postinstall` script of your `package.json` file:
The best way to get gRPC to work with electron is to do this, possibly in the `postinstall` script of your `package.json` file:
```
npm rebuild --target=2.0.0 --runtime=electron --dist-url=https://atom.io/download/electron

View File

@ -60,41 +60,38 @@
'-g',
'-Wall',
'-Wextra',
'-Werror',
'-Wno-long-long',
'-Wno-unused-parameter',
'-DOSATOMIC_USE_INLINED=1',
'-Wno-deprecated-declarations',
'-Ithird_party/nanopb',
'-DPB_FIELD_32BIT',
'-Ithird_party/upb',
'-Isrc/core/ext/upb-generated',
'-fvisibility=hidden',
],
'ldflags': [
'-g',
],
'cflags_c': [
'-Werror',
'-std=c99'
],
'cflags_cc': [
'-Werror',
'-std=c++1y'
],
'include_dirs': [
'deps/grpc',
'deps/grpc/include',
'deps/grpc/src/core/ext/upb-generated',
'deps/grpc/third_party/abseil-cpp',
'deps/grpc/third_party/address_sorting/include',
'deps/grpc/third_party/cares',
'deps/grpc/third_party/cares/cares',
'deps/grpc/third_party/abseil-cpp',
'deps/grpc/third_party/nanopb',
'deps/grpc/third_party/upb',
'deps/grpc/third_party/upb/generated_for_cmake',
],
'defines': [
'PB_FIELD_32BIT',
'GPR_BACKWARDS_COMPATIBILITY_MODE',
'GRPC_ARES=1',
'GRPC_UV',
'GRPC_NODE_VERSION="1.22.0-pre1"',
'GRPC_NODE_VERSION="1.24.0-pre1"',
'CARES_STATICLIB',
'CARES_SYMBOL_HIDING'
],
@ -190,26 +187,18 @@
'-g',
'-Wall',
'-Wextra',
'-Werror',
'-Wno-long-long',
'-Wno-unused-parameter',
'-DOSATOMIC_USE_INLINED=1',
'-Wno-deprecated-declarations',
'-Ithird_party/nanopb',
'-DPB_FIELD_32BIT',
'-Ithird_party/upb',
'-Isrc/core/ext/upb-generated',
'-fvisibility=hidden',
],
'OTHER_CPLUSPLUSFLAGS': [
'-g',
'-Wall',
'-Wextra',
'-Werror',
'-Wno-long-long',
'-Wno-unused-parameter',
'-DOSATOMIC_USE_INLINED=1',
'-Wno-deprecated-declarations',
'-Ithird_party/nanopb',
'-DPB_FIELD_32BIT',
'-Ithird_party/upb',
'-Isrc/core/ext/upb-generated',
'-fvisibility=hidden',
'-stdlib=libc++',
'-std=c++1y',
@ -688,7 +677,6 @@
'deps/grpc/src/core/lib/gpr/env_linux.cc',
'deps/grpc/src/core/lib/gpr/env_posix.cc',
'deps/grpc/src/core/lib/gpr/env_windows.cc',
'deps/grpc/src/core/lib/gpr/host_port.cc',
'deps/grpc/src/core/lib/gpr/log.cc',
'deps/grpc/src/core/lib/gpr/log_android.cc',
'deps/grpc/src/core/lib/gpr/log_linux.cc',
@ -715,6 +703,7 @@
'deps/grpc/src/core/lib/gprpp/arena.cc',
'deps/grpc/src/core/lib/gprpp/fork.cc',
'deps/grpc/src/core/lib/gprpp/global_config_env.cc',
'deps/grpc/src/core/lib/gprpp/host_port.cc',
'deps/grpc/src/core/lib/gprpp/thd_posix.cc',
'deps/grpc/src/core/lib/gprpp/thd_windows.cc',
'deps/grpc/src/core/lib/profiling/basic_timers.cc',
@ -779,6 +768,8 @@
'deps/grpc/src/core/lib/iomgr/ev_windows.cc',
'deps/grpc/src/core/lib/iomgr/exec_ctx.cc',
'deps/grpc/src/core/lib/iomgr/executor.cc',
'deps/grpc/src/core/lib/iomgr/executor/mpmcqueue.cc',
'deps/grpc/src/core/lib/iomgr/executor/threadpool.cc',
'deps/grpc/src/core/lib/iomgr/fork_posix.cc',
'deps/grpc/src/core/lib/iomgr/fork_windows.cc',
'deps/grpc/src/core/lib/iomgr/gethostname_fallback.cc',
@ -949,6 +940,7 @@
'deps/grpc/src/core/lib/security/security_connector/security_connector.cc',
'deps/grpc/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc',
'deps/grpc/src/core/lib/security/security_connector/ssl_utils.cc',
'deps/grpc/src/core/lib/security/security_connector/ssl_utils_config.cc',
'deps/grpc/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc',
'deps/grpc/src/core/lib/security/transport/client_auth_filter.cc',
'deps/grpc/src/core/lib/security/transport/secure_endpoint.cc',
@ -982,21 +974,23 @@
'deps/grpc/src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc',
'deps/grpc/src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc',
'deps/grpc/src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc',
'deps/grpc/src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc',
'deps/grpc/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc',
'deps/grpc/src/core/tsi/alts/handshaker/alts_tsi_utils.cc',
'deps/grpc/src/core/tsi/alts/handshaker/transport_security_common_api.cc',
'deps/grpc/src/core/tsi/alts/handshaker/altscontext.pb.c',
'deps/grpc/src/core/tsi/alts/handshaker/handshaker.pb.c',
'deps/grpc/src/core/tsi/alts/handshaker/transport_security_common.pb.c',
'deps/grpc/third_party/nanopb/pb_common.c',
'deps/grpc/third_party/nanopb/pb_decode.c',
'deps/grpc/third_party/nanopb/pb_encode.c',
'deps/grpc/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c',
'deps/grpc/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c',
'deps/grpc/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c',
'deps/grpc/third_party/upb/upb/decode.c',
'deps/grpc/third_party/upb/upb/encode.c',
'deps/grpc/third_party/upb/upb/msg.c',
'deps/grpc/third_party/upb/upb/port.c',
'deps/grpc/third_party/upb/upb/table.c',
'deps/grpc/third_party/upb/upb/upb.c',
'deps/grpc/src/core/tsi/transport_security.cc',
'deps/grpc/src/core/ext/transport/chttp2/client/insecure/channel_create.cc',
'deps/grpc/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc',
'deps/grpc/src/core/ext/transport/chttp2/client/authority.cc',
'deps/grpc/src/core/ext/transport/chttp2/client/chttp2_connector.cc',
'deps/grpc/src/core/ext/filters/client_channel/backend_metric.cc',
'deps/grpc/src/core/ext/filters/client_channel/backup_poller.cc',
'deps/grpc/src/core/ext/filters/client_channel/channel_connectivity.cc',
'deps/grpc/src/core/ext/filters/client_channel/client_channel.cc',
@ -1024,7 +1018,20 @@
'deps/grpc/src/core/ext/filters/client_channel/subchannel.cc',
'deps/grpc/src/core/ext/filters/client_channel/subchannel_pool_interface.cc',
'deps/grpc/src/core/ext/filters/deadline/deadline_filter.cc',
'deps/grpc/src/core/ext/filters/client_channel/health/health.pb.c',
'deps/grpc/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c',
'deps/grpc/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c',
'deps/grpc/src/core/ext/upb-generated/gogoproto/gogo.upb.c',
'deps/grpc/src/core/ext/upb-generated/validate/validate.upb.c',
'deps/grpc/src/core/ext/upb-generated/google/api/annotations.upb.c',
'deps/grpc/src/core/ext/upb-generated/google/api/http.upb.c',
'deps/grpc/src/core/ext/upb-generated/google/protobuf/any.upb.c',
'deps/grpc/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c',
'deps/grpc/src/core/ext/upb-generated/google/protobuf/duration.upb.c',
'deps/grpc/src/core/ext/upb-generated/google/protobuf/empty.upb.c',
'deps/grpc/src/core/ext/upb-generated/google/protobuf/struct.upb.c',
'deps/grpc/src/core/ext/upb-generated/google/protobuf/timestamp.upb.c',
'deps/grpc/src/core/ext/upb-generated/google/protobuf/wrappers.upb.c',
'deps/grpc/src/core/ext/upb-generated/google/rpc/status.upb.c',
'deps/grpc/src/core/tsi/fake_transport_security.cc',
'deps/grpc/src/core/tsi/local_transport_security.cc',
'deps/grpc/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc',
@ -1043,14 +1050,32 @@
'deps/grpc/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc',
'deps/grpc/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc',
'deps/grpc/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc',
'deps/grpc/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c',
'deps/grpc/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc',
'deps/grpc/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c',
'deps/grpc/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c',
'deps/grpc/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c',
'deps/grpc/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc',
'deps/grpc/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc',
'deps/grpc/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc',
'deps/grpc/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc',
'deps/grpc/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c',
'deps/grpc/src/core/ext/upb-generated/envoy/api/v2/cds.upb.c',
'deps/grpc/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c',
'deps/grpc/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c',
'deps/grpc/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c',
'deps/grpc/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c',
'deps/grpc/src/core/ext/upb-generated/envoy/api/v2/eds.upb.c',
'deps/grpc/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c',
'deps/grpc/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c',
'deps/grpc/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c',
'deps/grpc/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c',
'deps/grpc/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c',
'deps/grpc/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c',
'deps/grpc/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c',
'deps/grpc/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c',
'deps/grpc/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c',
'deps/grpc/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c',
'deps/grpc/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c',
'deps/grpc/src/core/ext/upb-generated/envoy/type/percent.upb.c',
'deps/grpc/src/core/ext/upb-generated/envoy/type/range.upb.c',
'deps/grpc/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc',
'deps/grpc/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc',
'deps/grpc/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc',
@ -1066,7 +1091,9 @@
'deps/grpc/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc',
'deps/grpc/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc',
'deps/grpc/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc',
'deps/grpc/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc',
'deps/grpc/src/core/ext/filters/census/grpc_context.cc',
'deps/grpc/src/core/ext/filters/client_idle/client_idle_filter.cc',
'deps/grpc/src/core/ext/filters/max_age/max_age_filter.cc',
'deps/grpc/src/core/ext/filters/message_size/message_size_filter.cc',
'deps/grpc/src/core/ext/filters/http/client_authority_filter.cc',

@ -1 +1 @@
Subproject commit 35230ef8cd70d62ab94bee661b7cd641adfa805b
Subproject commit f703e1c86c1504d9e48953f8da31f842679b7775

View File

@ -207,7 +207,7 @@ NAN_METHOD(Channel::New) {
if (info.IsConstructCall()) {
if (!info[0]->IsString()) {
return Nan::ThrowTypeError(
"Channel expects a string, a credential and an object");
"Channel's first argument (address) must be a string");
}
grpc_channel *wrapped_channel;
// Owned by the Channel object
@ -215,7 +215,7 @@ NAN_METHOD(Channel::New) {
grpc_channel_credentials *creds;
if (!ChannelCredentials::HasInstance(info[1])) {
return Nan::ThrowTypeError(
"Channel's second argument must be a ChannelCredentials");
"Channel's second argument (credentials) must be a ChannelCredentials");
}
ChannelCredentials *creds_object = ObjectWrap::Unwrap<ChannelCredentials>(
Nan::To<Object>(info[1]).ToLocalChecked());
@ -224,7 +224,7 @@ NAN_METHOD(Channel::New) {
if (!ParseChannelArgs(info[2], &channel_args_ptr)) {
DeallocateChannelArgs(channel_args_ptr);
return Nan::ThrowTypeError(
"Channel options must be an object with "
"Channel third argument (options) must be an object with "
"string keys and integer or string values");
}
if (creds == NULL) {

View File

@ -412,13 +412,13 @@ declare module "grpc" {
* User provided method to handle server streaming methods on the server.
*/
type handleServerStreamingCall<RequestType, ResponseType> =
(call: ServerWriteableStream<RequestType>) => void;
(call: ServerWritableStream<RequestType>) => void;
/**
* A stream that the server can write to. Used for calls that are streaming
* from the server side.
*/
export class ServerWriteableStream<RequestType> extends Writable {
export class ServerWritableStream<RequestType> extends Writable {
/**
* Indicates if the call has been cancelled
*/
@ -449,6 +449,10 @@ declare module "grpc" {
sendMetadata(responseMetadata: Metadata): void;
}
/* This typo existed in previous versions of this file, so we provide this
* type alias for backwards compatibility. */
export type ServerWriteableStream<RequestType> = ServerWritableStream<RequestType>;
/**
* User provided method to handle bidirectional streaming calls on the server.
*/
@ -579,7 +583,7 @@ declare module "grpc" {
* These options only have any effect when passed at the beginning of
* a client request.
*/
setOptions(options: MetadataOptions);
setOptions(options: MetadataOptions): void;
}
export type MetadataValue = string | Buffer;
@ -1127,7 +1131,7 @@ declare module "grpc" {
argument: RequestType,
metadata?: Metadata | null,
options?: CallOptions | null,
): ClientReadableStream<RequestType>;
): ClientReadableStream<ResponseType>;
/**
* Make a bidirectional stream request with this method on the given channel.
@ -1194,11 +1198,11 @@ declare module "grpc" {
* Indicates which properties of a parent call should propagate to this
* call. Bitwise combination of flags in `grpc.propagate`.
*/
propagate_flags: number;
propagate_flags?: number;
/**
* The credentials that should be used to make this particular call.
*/
credentials: CallCredentials;
credentials?: CallCredentials;
/**
* Additional custom call options. These can be used to pass additional
* data per-call to client interceptors

View File

@ -1,6 +1,6 @@
{
"name": "grpc",
"version": "1.22.0-pre1",
"version": "1.24.0-pre1",
"author": "Google Inc.",
"description": "gRPC Library for Node",
"homepage": "https://grpc.io/",
@ -29,7 +29,6 @@
"node-pre-gyp"
],
"dependencies": {
"@types/protobufjs": "^5.0.31",
"lodash.camelcase": "^4.3.0",
"lodash.clone": "^4.5.0",
"nan": "^2.13.2",
@ -68,13 +67,14 @@
"deps/grpc/include/grpc/**/*.h",
"deps/grpc/src/core/**/*.{c,cc,h}",
"deps/grpc/src/boringssl/err_data.c",
"deps/grpc/third_party/nanopb/*.{c,cc,h}",
"deps/grpc/third_party/zlib/**/*.{c,cc,h}",
"deps/grpc/third_party/abseil-cpp/absl/**/*.{h,hh}",
"deps/grpc/third_party/boringssl/crypto/**/*.{c,cc,h}",
"deps/grpc/third_party/boringssl/include/**/*.{c,cc,h}",
"deps/grpc/third_party/boringssl/ssl/**/*.{c,cc,h}",
"deps/grpc/third_party/boringssl/third_party/**/*.{c,h}",
"deps/grpc/third_party/abseil-cpp/absl/**/*.{h,hh}",
"deps/grpc/third_party/nanopb/*.{c,cc,h}",
"deps/grpc/third_party/upb/**/*.{c,h}",
"deps/grpc/third_party/zlib/**/*.{c,cc,h}",
"binding.gyp"
],
"main": "index.js",

View File

@ -688,6 +688,7 @@ function _getStreamReadCallback(emitter, call, get_listener, deserialize) {
try {
deserialized = deserialize(data);
} catch (e) {
common.log(constants.logVerbosity.ERROR, `Response deserialization failed: ${e.message}`);
emitter._readsDone({
code: constants.status.INTERNAL,
details: 'Failed to parse server response'
@ -829,6 +830,7 @@ function _getUnaryInterceptor(method_definition, channel, emitter, callback) {
try {
deserialized = deserialize(response.read);
} catch (e) {
common.log(constants.logVerbosity.ERROR, `Response deserialization failed: ${e.message}`);
/* Change status to indicate bad server response. This
* will result in passing an error to the callback */
status = {
@ -909,6 +911,7 @@ function _getClientStreamingInterceptor(method_definition, channel, emitter,
try {
deserialized = deserialize(response.read);
} catch (e) {
common.log(constants.logVerbosity.ERROR, `Response deserialization failed: ${e.message}`);
/* Change status to indicate bad server response. This will result
* in passing an error to the callback */
status = {
@ -933,6 +936,7 @@ function _getClientStreamingInterceptor(method_definition, channel, emitter,
try {
message = serialize(chunk);
} catch (e) {
common.log(constants.logVerbosity.ERROR, `Request serialization failed: ${e.message}`);
/* Sending this error to the server and emitting it immediately on the
client may put the call in a slightly weird state on the client side,
but passing an object that causes a serialization failure is a misuse
@ -1134,6 +1138,7 @@ function _getBidiStreamingInterceptor(method_definition, channel, emitter) {
try {
message = serialize(chunk);
} catch (e) {
common.log(constants.logVerbosity.ERROR, `Request serialization failed: ${e.message}`);
/* Sending this error to the server and emitting it immediately on the
client may put the call in a slightly weird state on the client side,
but passing an object that causes a serialization failure is a misuse

View File

@ -55,6 +55,9 @@ function handleError(call, error) {
if (error.hasOwnProperty('details')) {
status.details = error.details;
}
if (status.code == constants.status.INTERNAL) {
common.log(constants.logVerbosity.ERROR, error);
}
}
if (error.hasOwnProperty('metadata')) {
statusMetadata = error.metadata;

View File

@ -65,21 +65,22 @@
% endif
% endfor
'cflags_c': [
'-Werror',
'-std=c99'
],
'cflags_cc': [
'-Werror',
'-std=c++1y'
],
'include_dirs': [
'deps/grpc',
'deps/grpc/include',
'deps/grpc/src/core/ext/upb-generated',
'deps/grpc/third_party/abseil-cpp',
'deps/grpc/third_party/address_sorting/include',
'deps/grpc/third_party/cares',
'deps/grpc/third_party/cares/cares',
'deps/grpc/third_party/abseil-cpp',
'deps/grpc/third_party/nanopb',
'deps/grpc/third_party/upb',
'deps/grpc/third_party/upb/generated_for_cmake',
],
'defines': [
'PB_FIELD_32BIT',

View File

@ -31,7 +31,6 @@
"node-pre-gyp"
],
"dependencies": {
"@types/protobufjs": "^5.0.31",
"lodash.camelcase": "^4.3.0",
"lodash.clone": "^4.5.0",
"nan": "^2.13.2",
@ -70,13 +69,14 @@
"deps/grpc/include/grpc/**/*.h",
"deps/grpc/src/core/**/*.{c,cc,h}",
"deps/grpc/src/boringssl/err_data.c",
"deps/grpc/third_party/nanopb/*.{c,cc,h}",
"deps/grpc/third_party/zlib/**/*.{c,cc,h}",
"deps/grpc/third_party/abseil-cpp/absl/**/*.{h,hh}",
"deps/grpc/third_party/boringssl/crypto/**/*.{c,cc,h}",
"deps/grpc/third_party/boringssl/include/**/*.{c,cc,h}",
"deps/grpc/third_party/boringssl/ssl/**/*.{c,cc,h}",
"deps/grpc/third_party/boringssl/third_party/**/*.{c,h}",
"deps/grpc/third_party/abseil-cpp/absl/**/*.{h,hh}",
"deps/grpc/third_party/nanopb/*.{c,cc,h}",
"deps/grpc/third_party/upb/**/*.{c,h}",
"deps/grpc/third_party/zlib/**/*.{c,cc,h}",
"binding.gyp"
],
"main": "index.js",

View File

@ -14,7 +14,7 @@
set arch_list=ia32 x64
set electron_versions=1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 2.0.0 3.0.0 3.1.0 4.1.0 5.0.0
set electron_versions=1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 2.0.0 3.0.0 3.1.0 4.1.0 4.2.0 5.0.0
set PATH=%PATH%;C:\Program Files\nodejs\;%APPDATA%\npm

View File

@ -16,7 +16,7 @@
set -ex
arch_list=( ia32 x64 )
electron_versions=( 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 2.0.0 3.0.0 3.1.0 4.1.0 5.0.0 )
electron_versions=( 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 2.0.0 3.0.0 3.1.0 4.1.0 4.2.0 5.0.0 )
umask 022

View File

@ -1,6 +1,6 @@
{
"name": "@grpc/proto-loader",
"version": "0.5.1",
"version": "0.5.2",
"author": "Google Inc.",
"contributors": [
{

View File

@ -121,7 +121,7 @@ function getAllHandledReflectionObjects(
if (isHandledReflectionObject(obj)) {
return [[objName, obj]];
} else {
if (isNamespaceBase(obj) && typeof obj.nested !== undefined) {
if (isNamespaceBase(obj) && typeof obj.nested !== 'undefined') {
return Object.keys(obj.nested!)
.map((name) => {
return getAllHandledReflectionObjects(obj.nested![name], objName);