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

wsgrpc

Package Overview
Dependencies
Maintainers
1
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wsgrpc - npm Package Compare versions

Comparing version 1.6.2 to 1.6.3

21

lib/GrpcProtocol.js

@@ -135,3 +135,3 @@ "use strict";

return __awaiter(this, void 0, void 0, function () {
var stream, mdesc, e_1, e_2;
var stream, mdesc, e_1, request, e_2;
return __generator(this, function (_a) {

@@ -142,3 +142,2 @@ switch (_a.label) {

this.streams.set(streamID, stream);
this.listener && this.listener.onRequest(streamID, path, null);
_a.label = 1;

@@ -161,10 +160,14 @@ case 1:

case 4:
_a.trys.push([4, 6, 7, 8]);
return [4 /*yield*/, stream.handle()];
_a.trys.push([4, 7, 8, 9]);
return [4 /*yield*/, stream.handleRequest()];
case 5:
request = _a.sent();
this.listener && this.listener.onRequest(streamID, path, request);
return [4 /*yield*/, stream.handleResponse(request)];
case 6:
_a.sent();
this.sendResponseFinish(streamID);
this.listener && this.listener.onResponse(streamID, null);
return [3 /*break*/, 8];
case 6:
return [3 /*break*/, 9];
case 7:
e_2 = _a.sent();

@@ -174,7 +177,7 @@ console.warn("handle error:", e_2);

this.listener && this.listener.onError(streamID, e_2);
return [3 /*break*/, 8];
case 7:
return [3 /*break*/, 9];
case 8:
this.onStreamEnd(streamID);
return [7 /*endfinally*/];
case 8: return [2 /*return*/];
case 9: return [2 /*return*/];
}

@@ -181,0 +184,0 @@ });

@@ -16,3 +16,5 @@ /// <reference types="node" />

invoke(): Promise<Message<U>>;
handle(): Promise<void>;
handleRequest(): Promise<Message<T>>;
handleResponse(request: Message<T>): Promise<void>;
__old_handle(): Promise<void>;
sendRequest(): Promise<void>;

@@ -19,0 +21,0 @@ readMessageStream(mtype: any, hasTrailers?: boolean): AsyncIterableIterator<any>;

@@ -91,8 +91,69 @@ "use strict";

};
GrpcStream.prototype.handle = function () {
GrpcStream.prototype.handleRequest = function () {
return __awaiter(this, void 0, void 0, function () {
var e_1, _a, request, response, data, message, response_1, response_1_1, data, message, e_1_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!this.method.requestStream) return [3 /*break*/, 1];
return [2 /*return*/, this.readMessageStream(this.method.requestType, false)];
case 1: return [4 /*yield*/, this.readMessageUnary(this.method.requestType, false)];
case 2: return [2 /*return*/, _a.sent()];
}
});
});
};
GrpcStream.prototype.handleResponse = function (request) {
return __awaiter(this, void 0, void 0, function () {
var e_1, _a, response, data, message, response_1, response_1_1, data, message, e_1_1;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
response = this.handler(request);
if (!!this.method.responseStream) return [3 /*break*/, 2];
return [4 /*yield*/, response];
case 1:
data = _b.sent();
message = this.method.responseType.encode(data).finish();
this.protocol.sendMessage(this.streamID, message);
return [3 /*break*/, 13];
case 2:
_b.trys.push([2, 7, 8, 13]);
response_1 = __asyncValues(response);
_b.label = 3;
case 3: return [4 /*yield*/, response_1.next()];
case 4:
if (!(response_1_1 = _b.sent(), !response_1_1.done)) return [3 /*break*/, 6];
data = response_1_1.value;
message = this.method.responseType.encode(data).finish();
this.protocol.sendMessage(this.streamID, message);
_b.label = 5;
case 5: return [3 /*break*/, 3];
case 6: return [3 /*break*/, 13];
case 7:
e_1_1 = _b.sent();
e_1 = { error: e_1_1 };
return [3 /*break*/, 13];
case 8:
_b.trys.push([8, , 11, 12]);
if (!(response_1_1 && !response_1_1.done && (_a = response_1.return))) return [3 /*break*/, 10];
return [4 /*yield*/, _a.call(response_1)];
case 9:
_b.sent();
_b.label = 10;
case 10: return [3 /*break*/, 12];
case 11:
if (e_1) throw e_1.error;
return [7 /*endfinally*/];
case 12: return [7 /*endfinally*/];
case 13: return [2 /*return*/];
}
});
});
};
GrpcStream.prototype.__old_handle = function () {
return __awaiter(this, void 0, void 0, function () {
var e_2, _a, request, response, data, message, response_2, response_2_1, data, message, e_2_1;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!this.method.requestStream) return [3 /*break*/, 1];

@@ -116,8 +177,8 @@ request = this.readMessageStream(this.method.requestType, false);

_b.trys.push([5, 10, 11, 16]);
response_1 = __asyncValues(response);
response_2 = __asyncValues(response);
_b.label = 6;
case 6: return [4 /*yield*/, response_1.next()];
case 6: return [4 /*yield*/, response_2.next()];
case 7:
if (!(response_1_1 = _b.sent(), !response_1_1.done)) return [3 /*break*/, 9];
data = response_1_1.value;
if (!(response_2_1 = _b.sent(), !response_2_1.done)) return [3 /*break*/, 9];
data = response_2_1.value;
message = this.method.responseType.encode(data).finish();

@@ -129,9 +190,9 @@ this.protocol.sendMessage(this.streamID, message);

case 10:
e_1_1 = _b.sent();
e_1 = { error: e_1_1 };
e_2_1 = _b.sent();
e_2 = { error: e_2_1 };
return [3 /*break*/, 16];
case 11:
_b.trys.push([11, , 14, 15]);
if (!(response_1_1 && !response_1_1.done && (_a = response_1.return))) return [3 /*break*/, 13];
return [4 /*yield*/, _a.call(response_1)];
if (!(response_2_1 && !response_2_1.done && (_a = response_2.return))) return [3 /*break*/, 13];
return [4 /*yield*/, _a.call(response_2)];
case 12:

@@ -142,3 +203,3 @@ _b.sent();

case 14:
if (e_1) throw e_1.error;
if (e_2) throw e_2.error;
return [7 /*endfinally*/];

@@ -154,3 +215,3 @@ case 15: return [7 /*endfinally*/];

return __awaiter(this, void 0, void 0, function () {
var e_2, _a, message, _b, _c, data, message, e_2_1;
var e_3, _a, message, _b, _c, data, message, e_3_1;
return __generator(this, function (_d) {

@@ -177,4 +238,4 @@ switch (_d.label) {

case 6:
e_2_1 = _d.sent();
e_2 = { error: e_2_1 };
e_3_1 = _d.sent();
e_3 = { error: e_3_1 };
return [3 /*break*/, 12];

@@ -190,3 +251,3 @@ case 7:

case 10:
if (e_2) throw e_2.error;
if (e_3) throw e_3.error;
return [7 /*endfinally*/];

@@ -193,0 +254,0 @@ case 11: return [7 /*endfinally*/];

@@ -90,4 +90,4 @@ "use strict";

if (!(passed > 2 * interval)) return [3 /*break*/, 2];
console.debug("ping pong timeout, close socket");
ws.close();
// console.debug("ping pong timeout, close socket");
// ws.close();
return [2 /*return*/];

@@ -94,0 +94,0 @@ case 2:

{
"name": "wsgrpc",
"version": "1.6.2",
"version": "1.6.3",
"description": "Using WebSocket as gRPC transport",

@@ -5,0 +5,0 @@ "author": "tsangpo",

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