ts-proto 1.164.1 → 1.164.2

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.
@@ -301,13 +301,6 @@ function createObservableUnaryMethod(ctx) {
301
301
  function createInvokeMethod(ctx) {
302
302
  const { options } = ctx;
303
303
  const { useAbortSignal } = options;
304
- const maybeAbortSignal = useAbortSignal
305
- ? `
306
- if (abortSignal) abortSignal.addEventListener("abort", () => {
307
- observer.error(abortSignal.reason);
308
- client.close();
309
- });`
310
- : "";
311
304
  return (0, ts_poet_1.code) `
312
305
  invoke<T extends UnaryMethodDefinitionish>(
313
306
  methodDesc: T,
@@ -344,14 +337,27 @@ function createInvokeMethod(ctx) {
344
337
  }
345
338
  },
346
339
  });
347
- observer.add(() => {
348
- ${!useAbortSignal
349
- ? `return client.close();`
350
- : `if (!abortSignal || !abortSignal.aborted)
351
- return client.close();`}
352
- });
340
+ ${useAbortSignal
341
+ ? `
342
+ if (abortSignal) {
343
+ const abort = () => {
344
+ observer.error(abortSignal.reason);
345
+ client.close();
346
+ };
347
+ abortSignal.addEventListener("abort", abort);
348
+ observer.add(() => {
349
+ if (abortSignal.aborted) {
350
+ return;
351
+ }
353
352
 
354
- ${maybeAbortSignal}
353
+ abortSignal.removeEventListener('abort', abort);
354
+ client.close();
355
+ });
356
+ } else {
357
+ observer.add(() => client.close());
358
+ }
359
+ `
360
+ : `observer.add(() => client.close());`}
355
361
  });
356
362
  upStream();
357
363
  }).pipe(${share}());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-proto",
3
- "version": "1.164.1",
3
+ "version": "1.164.2",
4
4
  "description": "",
5
5
  "main": "build/plugin.js",
6
6
  "repository": "github:stephenh/ts-proto",