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.0.10 to 0.1.0

24

lib/handler.js

@@ -62,8 +62,9 @@ 'use strict';

try {
this.outstandingWrites++;
const response = await this[kCall].serializeMessage(chunk);
this[kCall].write(response);
this.outstandingWrites--;
if (this[kCall].write(response) === false) {
this[kCall].once('drain', callback);
return;
}
} catch (err) {
this.outstandingWrites = 0;
err.code = Status.INTERNAL;

@@ -73,2 +74,7 @@ this.emit('error', err);

callback();
}
_final (callback) {
this[kCall].end();
callback(null);

@@ -78,8 +84,2 @@ }

end (metadata) {
// If there are still writes pending, do not end the HTTP2 stream.
if (this.outstandingWrites > 0) {
setImmediate(this.end.bind(this), metadata);
return;
}
if (metadata) {

@@ -89,3 +89,2 @@ this[kCall].status.metadata = metadata;

this[kCall].end(undefined);
Writable.prototype.end.call(this);

@@ -120,2 +119,3 @@ }

ServerDuplexStream.prototype._write = ServerWritableStream.prototype._write;
ServerDuplexStream.prototype._final = ServerWritableStream.prototype._final;
ServerDuplexStream.prototype.end = ServerWritableStream.prototype.end;

@@ -191,4 +191,2 @@ ServerDuplexStream.prototype.serialize =

function setUpWritable (stream) {
stream.outstandingWrites = 0;
stream.on('error', (err) => {

@@ -195,0 +193,0 @@ stream[kCall].sendError(err);

'use strict';
const { ServerCredentials } = require('@grpc/grpc-js');
const { Server } = require('./server');
const { ServerCredentials } = require('./server-credentials');
module.exports = { Server, ServerCredentials };

@@ -37,3 +37,5 @@ 'use strict';

this.compression = new CompressionFilter();
this.metadataSent = false;
this.status = { code: Status.OK, details: 'OK', metadata: null };
this.stream.on('drain', onStreamDrain.bind(this));
this.stream.once('error', onStreamError.bind(this));

@@ -44,6 +46,8 @@ this.stream.once('close', onStreamClose.bind(this));

sendMetadata (customMetadata) {
if (this.stream.headersSent === true) {
if (this.metadataSent === true) {
return;
}
this.metadataSent = true;
const headers = {

@@ -172,3 +176,3 @@ [kGrpcEncodingHeader]: this.compression.send.name,

this.end(undefined);
this.end();
}

@@ -203,2 +207,7 @@

function onStreamDrain () {
// `this` is bound to the Call instance, not the stream itself.
this.emit('drain');
}
function onStreamError (err) {

@@ -205,0 +214,0 @@ // `this` is bound to the Call instance, not the stream itself.

'use strict';
const Http2 = require('http2');
const { URL } = require('url');
const { status } = require('@grpc/grpc-js');
const { status, ServerCredentials } = require('@grpc/grpc-js');
const {

@@ -12,3 +12,2 @@ ServerDuplexStream,

const { ServerCall } = require('./server-call');
const { ServerCredentials } = require('./server-credentials');
const kHandlers = Symbol('handlers');

@@ -65,4 +64,2 @@ const kServer = Symbol('server');

const { secure } = creds;
if (typeof port === 'string') {

@@ -73,4 +70,4 @@ const url = new URL(`http://${port}`);

if (secure) {
this[kServer] = Http2.createSecureServer(creds.settings);
if (creds._isSecure()) {
this[kServer] = Http2.createSecureServer(creds._getSettings());
} else {

@@ -211,3 +208,3 @@ this[kServer] = Http2.createServer();

if (handler === undefined) {
throw new Error('no matching handler');
return call.sendError(unimplementedStatusResponse);
}

@@ -214,0 +211,0 @@

{
"name": "grpc-server-js",
"version": "0.0.10",
"version": "0.1.0",
"description": "Pure JavaScript gRPC Server",

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

"engines": {
"node": ">=10.0.0"
"node": ">=10.10.0"
},
"dependencies": {
"@grpc/grpc-js": "0.3.6"
"@grpc/grpc-js": "0.4.0"
},

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

@@ -12,3 +12,3 @@ # grpc-server-js

The goal is to be largely compatible with the existing [`Server`](https://grpc.io/grpc/node/grpc.Server.html) and [`ServerCredentials`](https://grpc.io/grpc/node/grpc.ServerCredentials.html) documentation.
The goal is to be largely compatible with the existing [`Server`](https://grpc.io/grpc/node/grpc.Server.html) implementation.

@@ -32,4 +32,2 @@ ## Features

- `Server.prototype.forceShutdown()` is not implemented.
- The `private_key` and `cert_chain` properties of `keyCertPair` instances have
been renamed to `privateKey` and `certChain`.

@@ -36,0 +34,0 @@ ## Acknowledgement

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