From 05c9a7aea7a0e75d4a2a24cc251f59bb2aa4c1f0 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 8 Apr 2023 14:38:29 -0400 Subject: [PATCH] *Update dist --- dist/query/simple.js | 2 +- dist/util.d.ts | 2 +- dist/util.d.ts.map | 2 +- dist/util.js | 11 +++++++---- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/dist/query/simple.js b/dist/query/simple.js index 51c67a0..b9ff937 100644 --- a/dist/query/simple.js +++ b/dist/query/simple.js @@ -42,7 +42,7 @@ export default class SimpleRpcQuery extends RpcQueryBase { } this._relay = socket; await socket.opened; - const rpc = setupStream(socket); + const rpc = await setupStream(socket); if (this._query.bypassCache) { delete this._query.bypassCache; await this.queryRpc(rpc, { diff --git a/dist/util.d.ts b/dist/util.d.ts index d5408a7..bc066ee 100644 --- a/dist/util.d.ts +++ b/dist/util.d.ts @@ -14,6 +14,6 @@ export declare function validateTimestampedResponse( ): boolean; export declare function hashQuery(query: RPCRequest): string; export declare function createHash(data: string): Buffer; -export declare function setupStream(stream: any): any; +export declare function setupStream(stream: any): Promise; export declare function maybeGetAsyncProperty(object: any): Promise; //# sourceMappingURL=util.d.ts.map diff --git a/dist/util.d.ts.map b/dist/util.d.ts.map index 5c86728..c0a84d5 100644 --- a/dist/util.d.ts.map +++ b/dist/util.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAOxE,eAAO,MAAM,mBAAmB,eAAwB,CAAC;AAEzD,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,WAM1C;AAKD,wBAAgB,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,GAAE,GAAQ,GAAG,GAAG,EAAE,CA0C1D;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,WAAW,EACrB,WAAW,UAAQ,GAClB,OAAO,CAkBT;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,WAAW,GACpB,OAAO,CAET;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAUnD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM/C;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,GAAG,OAStC;AAED,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,GAAG,gBAUtD"} \ No newline at end of file +{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAOxE,eAAO,MAAM,mBAAmB,eAAwB,CAAC;AAEzD,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,WAM1C;AAKD,wBAAgB,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,GAAE,GAAQ,GAAG,GAAG,EAAE,CA0C1D;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,WAAW,EACrB,WAAW,UAAQ,GAClB,OAAO,CAkBT;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,WAAW,GACpB,OAAO,CAET;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAUnD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM/C;AAED,wBAAsB,WAAW,CAAC,MAAM,EAAE,GAAG,gBAa5C;AAED,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,GAAG,gBAUtD"} \ No newline at end of file diff --git a/dist/util.js b/dist/util.js index 2dcfa72..6178477 100644 --- a/dist/util.js +++ b/dist/util.js @@ -80,13 +80,16 @@ export function createHash(data) { sodium.crypto_generichash(hash, buffer); return hash; } -export function setupStream(stream) { +export async function setupStream(stream) { const existing = stream[RPC_PROTOCOL_SYMBOL]; - if (existing) { + if (!existing) { + await existing._channel.ready; return existing; } - stream[RPC_PROTOCOL_SYMBOL] = new RPC(stream); - return stream[RPC_PROTOCOL_SYMBOL]; + const rpc = new RPC(stream); + stream[RPC_PROTOCOL_SYMBOL] = rpc; + await existing.ready; + return rpc; } export async function maybeGetAsyncProperty(object) { if (typeof object === "function") {