glitchgrab 1.66.2 → 1.67.0

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/dist/server.js CHANGED
@@ -315,6 +315,7 @@ function signSession(options) {
315
315
  }
316
316
  var GUIDES_REVALIDATE_SECONDS = 300;
317
317
  var SDK_API_TIMEOUT_MS = 5e3;
318
+ var SDK_LINE_REQUEST_TIMEOUT_MS = 4e4;
318
319
  async function callSdkApi(path, token, options, init) {
319
320
  var _a, _b, _c, _d, _e, _f;
320
321
  const baseUrl = ((_c = (_b = (_a = options.baseUrl) != null ? _a : defaults.baseUrl) != null ? _b : readEnv("GLITCHGRAB_BASE_URL")) != null ? _c : DEFAULT_BASE_URL).replace(/\/+$/, "");
@@ -342,7 +343,10 @@ async function callSdkApi(path, token, options, init) {
342
343
  };
343
344
  }
344
345
  return { data: (_f = body.data) != null ? _f : null, error: null };
345
- } catch (e) {
346
+ } catch (err) {
347
+ if ((controller == null ? void 0 : controller.signal.aborted) || err instanceof Error && err.name === "AbortError") {
348
+ return { data: null, error: "Glitchgrab took too long", code: "TIMEOUT" };
349
+ }
346
350
  return { data: null, error: "Could not reach Glitchgrab" };
347
351
  } finally {
348
352
  if (timer) clearTimeout(timer);
@@ -1033,10 +1037,16 @@ async function getPhoneLine(params = {}, options = {}) {
1033
1037
  }
1034
1038
  }
1035
1039
  async function lineRequestCall(path, body, options) {
1040
+ var _a;
1036
1041
  try {
1037
1042
  const key = callsKey(options);
1038
1043
  if (!key) return { ok: false, error: NO_KEY_ERROR };
1039
- const { data, error, code } = await callSdkApi(path, key, options, { method: "POST", body, cache: "no-store" });
1044
+ const { data, error, code } = await callSdkApi(
1045
+ path,
1046
+ key,
1047
+ { ...options, timeoutMs: (_a = options.timeoutMs) != null ? _a : SDK_LINE_REQUEST_TIMEOUT_MS },
1048
+ { method: "POST", body, cache: "no-store" }
1049
+ );
1040
1050
  const request = isRecord(data) ? lineRequestOf(data.request) : null;
1041
1051
  if (error !== null || !request) return { ok: false, error: error != null ? error : "Unexpected response", ...code ? { code } : {} };
1042
1052
  return { ok: true, request };