@milaboratories/pl-client 2.5.3 → 2.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milaboratories/pl-client",
3
- "version": "2.5.3",
3
+ "version": "2.5.5",
4
4
  "description": "New TS/JS client for Platform API",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -17,7 +17,7 @@
17
17
  "./src/**/*"
18
18
  ],
19
19
  "dependencies": {
20
- "@grpc/grpc-js": "^1.12.0",
20
+ "@grpc/grpc-js": "^1.12.2",
21
21
  "@protobuf-ts/grpc-transport": "^2.9.4",
22
22
  "@protobuf-ts/runtime": "^2.9.4",
23
23
  "@protobuf-ts/runtime-rpc": "^2.9.4",
@@ -27,14 +27,14 @@
27
27
  "https-proxy-agent": "^7.0.5",
28
28
  "cacheable-lookup": "^6.1.0",
29
29
  "long": "^5.2.3",
30
- "undici": "^6.19.8",
30
+ "undici": "^6.20.1",
31
31
  "utility-types": "^3.11.0",
32
- "yaml": "^2.5.1",
32
+ "yaml": "^2.6.0",
33
33
  "@milaboratories/ts-helpers": "^1.1.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "typescript": "~5.5.4",
37
- "vite": "^5.4.8",
37
+ "vite": "^5.4.10",
38
38
  "@types/node": "~20.16.10",
39
39
  "@protobuf-ts/plugin": "^2.9.4",
40
40
  "@types/http-proxy": "^1.17.15",
@@ -106,7 +106,7 @@ export class LLPlClient {
106
106
 
107
107
  const httpOptions: Client.Options = {
108
108
  // allowH2: true,
109
- headersTimeout: 3e3,
109
+ headersTimeout: 5e3,
110
110
  keepAliveTimeout: 3e3,
111
111
  keepAliveMaxTimeout: 60e3,
112
112
  maxRedirections: 6,
@@ -152,6 +152,8 @@ export class PlTransaction {
152
152
  * pending ops, to throw any pending errors. */
153
153
  private pendingVoidOps: Promise<void>[] = [];
154
154
 
155
+ private globalTxIdWasAwaited: boolean = false;
156
+
155
157
  constructor(
156
158
  private readonly ll: LLPlTransaction,
157
159
  public readonly name: string,
@@ -173,6 +175,13 @@ export class PlTransaction {
173
175
  },
174
176
  (r) => notEmpty(r.txOpen.tx?.id)
175
177
  );
178
+
179
+ // To avoid floating promise
180
+ this.globalTxId.catch((err) => {
181
+ if (!this.globalTxIdWasAwaited) {
182
+ console.warn(err);
183
+ }
184
+ });
176
185
  }
177
186
 
178
187
  private async drainAndAwaitPendingOps(): Promise<void> {
@@ -192,10 +201,12 @@ export class PlTransaction {
192
201
  // pushing operation packet to server
193
202
  const rawResponsePromise = this.ll.send(r, false);
194
203
 
195
- await this.drainAndAwaitPendingOps();
196
-
197
- // awaiting our result, and parsing the response
198
- return parser(await rawResponsePromise);
204
+ try {
205
+ await this.drainAndAwaitPendingOps();
206
+ } finally {
207
+ // awaiting our result, and parsing the response
208
+ return parser(await rawResponsePromise);
209
+ }
199
210
  }
200
211
 
201
212
  private async sendMultiAndParse<Kind extends NonUndefined<ClientMessageRequest['oneofKind']>, T>(
@@ -205,10 +216,12 @@ export class PlTransaction {
205
216
  // pushing operation packet to server
206
217
  const rawResponsePromise = this.ll.send(r, true);
207
218
 
208
- await this.drainAndAwaitPendingOps();
209
-
210
- // awaiting our result, and parsing the response
211
- return parser(await rawResponsePromise);
219
+ try {
220
+ await this.drainAndAwaitPendingOps();
221
+ } finally {
222
+ // awaiting our result, and parsing the response
223
+ return parser(await rawResponsePromise);
224
+ }
212
225
  }
213
226
 
214
227
  private async sendVoidSync<Kind extends NonUndefined<ClientMessageRequest['oneofKind']>, T>(
@@ -247,6 +260,7 @@ export class PlTransaction {
247
260
  await completeResult;
248
261
  await this.ll.await();
249
262
  } else {
263
+ // @TODO, also floating promises
250
264
  const commitResponse = this.sendSingleAndParse(
251
265
  { oneofKind: 'txCommit', txCommit: {} },
252
266
  (r) => r.txCommit.success
@@ -773,6 +787,7 @@ export class PlTransaction {
773
787
  //
774
788
 
775
789
  public async getGlobalTxId() {
790
+ this.globalTxIdWasAwaited = true;
776
791
  return await this.globalTxId;
777
792
  }
778
793