🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

bare-rpc

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bare-rpc - npm Package Compare versions

Comparing version
1.3.4
to
1.3.5
+2
-0
index.d.ts

@@ -98,2 +98,4 @@ import Buffer, { BufferEncoding } from 'bare-buffer'

interface RPC {
readonly idle: boolean
event(command: number): RPCOutgoingEvent

@@ -100,0 +102,0 @@ request(command: number): RPCOutgoingRequest

@@ -45,2 +45,15 @@ const safetyCatch = require('safety-catch')

// Whether there are no requests or responses currently in flight. Useful for
// determining when it is safe to tear down the underlying stream.
get idle() {
return (
this._outgoingRequests.size === 0 &&
this._outgoingResponses.size === 0 &&
this._incomingRequests.size === 0 &&
this._incomingResponses.size === 0 &&
this._pendingRequests.size === 0 &&
this._pendingResponses.size === 0
)
}
event(command) {

@@ -94,2 +107,4 @@ return new OutgoingEvent(this, command)

request._requestStream = new OutgoingStream(this, request, t.REQUEST, opts)
request._requestStream.on('close', () => this._gcOutgoingRequest(request))
} else {

@@ -119,2 +134,4 @@ this._incomingRequests.set(request.id, request)

request._responseStream = new OutgoingStream(this, request, t.RESPONSE, opts)
request._responseStream.on('close', () => this._outgoingResponses.delete(request.id))
} else {

@@ -125,3 +142,8 @@ this._incomingResponses.set(request.id, request)

request._responseStream.on('close', () => this._incomingResponses.delete(request.id))
request._responseStream.on('close', () => {
this._incomingResponses.delete(request.id)
request._responded = true
this._gcOutgoingRequest(request)
})
}

@@ -140,2 +162,13 @@ }

_gcOutgoingRequest(request) {
// The entry must stay reachable for as long as an incoming message might
// still target it; until the response has settled and, if the request was
// streamed, until the outgoing request stream has closed. Either can be the
// last to arrive, so only remove the entry once both have completed.
if (!request._responded) return
if (request._requestStream !== null && !request._requestStream.destroyed) return
this._outgoingRequests.delete(request.id)
}
_onerror(err) {

@@ -234,4 +267,10 @@ this._ondrain(err)

if (message.error) {
request._responded = true
this._gcOutgoingRequest(request)
request._reject(message.error)
} else if (message.stream === 0) {
request._responded = true
this._gcOutgoingRequest(request)
request._resolve(message.data)

@@ -238,0 +277,0 @@ }

@@ -12,2 +12,4 @@ const c = require('compact-encoding')

this._responded = false
this._promise = new Promise((resolve, reject) => {

@@ -14,0 +16,0 @@ this._resolve = resolve

+1
-1
{
"name": "bare-rpc",
"version": "1.3.4",
"version": "1.3.5",
"description": "librpc ABI compatible RPC for Bare",

@@ -5,0 +5,0 @@ "exports": {