@loyaltte/node 0.1.0 → 0.1.1

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @loyaltte/node 0.1.0
1
+ # @loyaltte/node 0.1.1
2
2
 
3
3
  Loyaltte for Node.js servers: record bills and returns **exactly once**, look up customers and their points, send events, sign customers in for the app SDKs, and verify webhooks.
4
4
 
@@ -92,13 +92,17 @@ class Transport {
92
92
  const retriesLeft = attempt <= maxRetries && slept < exports.RETRY.maxTotalSleepMs;
93
93
  let response;
94
94
  let text;
95
+ // A plain timer (not AbortSignal.timeout, whose timer is unref'd on Node 18) so the timeout always fires,
96
+ // covering the body read too; cleared as soon as the attempt ends.
97
+ const controller = new AbortController();
98
+ const timer = setTimeout(() => controller.abort(new DOMException("The request timed out.", "TimeoutError")), timeoutMs);
95
99
  try {
96
100
  response = await fetch(url, {
97
101
  method: operation.method,
98
102
  headers,
99
103
  body,
100
104
  redirect: "error", // never follow a redirect with the key attached
101
- signal: AbortSignal.timeout(timeoutMs),
105
+ signal: controller.signal,
102
106
  });
103
107
  text = await response.text();
104
108
  }
@@ -116,6 +120,9 @@ class Transport {
116
120
  }
117
121
  throw this.#connectionError(error);
118
122
  }
123
+ finally {
124
+ clearTimeout(timer);
125
+ }
119
126
  if (response.ok)
120
127
  return this.#parse(response, text);
121
128
  const failure = this.#failure(response, text);
@@ -1,2 +1,2 @@
1
1
  /** The SDK's own version: sent as `X-Loyaltte-SDK: node/<version>` on every call. Kept equal to package.json. */
2
- export declare const VERSION = "0.1.0";
2
+ export declare const VERSION = "0.1.1";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  /** The SDK's own version: sent as `X-Loyaltte-SDK: node/<version>` on every call. Kept equal to package.json. */
5
- exports.VERSION = "0.1.0";
5
+ exports.VERSION = "0.1.1";
@@ -88,13 +88,17 @@ export class Transport {
88
88
  const retriesLeft = attempt <= maxRetries && slept < RETRY.maxTotalSleepMs;
89
89
  let response;
90
90
  let text;
91
+ // A plain timer (not AbortSignal.timeout, whose timer is unref'd on Node 18) so the timeout always fires,
92
+ // covering the body read too; cleared as soon as the attempt ends.
93
+ const controller = new AbortController();
94
+ const timer = setTimeout(() => controller.abort(new DOMException("The request timed out.", "TimeoutError")), timeoutMs);
91
95
  try {
92
96
  response = await fetch(url, {
93
97
  method: operation.method,
94
98
  headers,
95
99
  body,
96
100
  redirect: "error", // never follow a redirect with the key attached
97
- signal: AbortSignal.timeout(timeoutMs),
101
+ signal: controller.signal,
98
102
  });
99
103
  text = await response.text();
100
104
  }
@@ -112,6 +116,9 @@ export class Transport {
112
116
  }
113
117
  throw this.#connectionError(error);
114
118
  }
119
+ finally {
120
+ clearTimeout(timer);
121
+ }
115
122
  if (response.ok)
116
123
  return this.#parse(response, text);
117
124
  const failure = this.#failure(response, text);
@@ -1,2 +1,2 @@
1
1
  /** The SDK's own version: sent as `X-Loyaltte-SDK: node/<version>` on every call. Kept equal to package.json. */
2
- export declare const VERSION = "0.1.0";
2
+ export declare const VERSION = "0.1.1";
@@ -1,2 +1,2 @@
1
1
  /** The SDK's own version: sent as `X-Loyaltte-SDK: node/<version>` on every call. Kept equal to package.json. */
2
- export const VERSION = "0.1.0";
2
+ export const VERSION = "0.1.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loyaltte/node",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Loyaltte for Node.js servers: record bills and returns exactly once, look up customers and points, send events, sign customers in for the app SDKs, and verify webhooks. Zero dependencies.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://developers.loyaltte.com/",