Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grpc-server-js

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grpc-server-js - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

lib/server-session.js

4

lib/server-call.js

@@ -178,3 +178,3 @@ 'use strict';

write (chunk) {
if (this.cancelled === true) {
if (this.cancelled === true || this.stream.destroyed === true) {
return;

@@ -188,3 +188,3 @@ }

end (payload) {
if (this.cancelled === true) {
if (this.cancelled === true || this.stream.destroyed === true) {
return;

@@ -191,0 +191,0 @@ }

@@ -12,5 +12,8 @@ 'use strict';

const { ServerCall } = require('./server-call');
const { ServerSession } = require('./server-session');
const kHandlers = Symbol('handlers');
const kServer = Symbol('server');
const kStarted = Symbol('started');
const kOptions = Symbol('options');
const kSessionOptions = Symbol('sessionOptions');
const kUnaryHandlerType = 0;

@@ -28,3 +31,2 @@ const kClientStreamHandlerType = 1;

const unimplementedStatusResponse = {

@@ -40,3 +42,2 @@ code: status.UNIMPLEMENTED,

const defaultHandler = [

@@ -57,11 +58,26 @@ function unary (call, callback) {

function noop () {}
const defaultHttp2Settings = Http2.getDefaultSettings();
const defaultServerOptions = {
'grpc.http2.max_frame_size': defaultHttp2Settings.maxFrameSize,
'grpc.keepalive_time_ms': 7200000, // 2 hours in ms (spec default).
'grpc.keepalive_timeout_ms': 20000 // 20 seconds in ms (spec default).
};
class Server {
constructor () {
constructor (options = {}) {
if (options === null || typeof options !== 'object') {
throw new TypeError('options must be an object');
}
this[kServer] = null;
this[kHandlers] = new Map();
this[kStarted] = false;
this[kOptions] = { ...defaultServerOptions, ...options };
this[kSessionOptions] = {
keepaliveTimeMs: this[kOptions]['grpc.keepalive_time_ms'],
keepaliveTimeoutMs: this[kOptions]['grpc.keepalive_timeout_ms']
};
}

@@ -112,9 +128,16 @@

const options = { host: url.hostname, port: +url.port };
const http2ServerOptions = {
maxFrameSize: this[kOptions]['grpc.http2.max_frame_size']
};
if (creds._isSecure()) {
this[kServer] = Http2.createSecureServer(creds._getSettings());
this[kServer] = Http2.createSecureServer({
...http2ServerOptions,
...creds._getSettings()
});
} else {
this[kServer] = Http2.createServer();
this[kServer] = Http2.createServer(http2ServerOptions);
}
this[kServer].timeout = 0;
setupHandlers(this);

@@ -249,9 +272,5 @@

function setupHandlers (grpcServer) {
grpcServer[kServer].on('stream', (stream, headers) => {
if (grpcServer[kStarted] !== true) {
stream.respond();
stream.end();
return;
}
const http2Server = grpcServer[kServer];
http2Server.on('stream', (stream, headers) => {
const contentType = headers[HTTP2_HEADER_CONTENT_TYPE];

@@ -284,2 +303,14 @@

});
http2Server.on('session', (session) => {
if (grpcServer[kStarted] !== true) {
session.destroy();
return;
}
const grpcSession = new ServerSession(session, grpcServer[kSessionOptions]);
// The client has connected, so begin sending keepalive pings.
grpcSession.startKeepalivePings();
});
}

@@ -286,0 +317,0 @@

{
"name": "grpc-server-js",
"version": "0.1.3",
"version": "0.1.4",
"description": "Pure JavaScript gRPC Server",

@@ -26,3 +26,3 @@ "author": "Colin J. Ihrig <cjihrig@gmail.com> (http://www.cjihrig.com/)",

"dependencies": {
"@grpc/grpc-js": "0.4.0"
"@grpc/grpc-js": "0.4.2"
},

@@ -29,0 +29,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc