spur-board 0.38.0 → 0.38.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.
Files changed (2) hide show
  1. package/dist/daemon.mjs +121 -89
  2. package/package.json +1 -1
package/dist/daemon.mjs CHANGED
@@ -14522,6 +14522,26 @@ function retryAt(headers, now) {
14522
14522
  if (!Number.isNaN(at)) return new Date(at);
14523
14523
  }
14524
14524
  }
14525
+ /** Longest a GitHub or Jira request may take, body read included. */
14526
+ const REQUEST_TIMEOUT_MS$1 = 3e4;
14527
+ /**
14528
+ * Runs one request under `signal` and a {@link REQUEST_TIMEOUT_MS} timer. A timeout rejects as a
14529
+ * `transient` error with `message`; a caller abort passes through unchanged.
14530
+ */
14531
+ async function withTimeout(signal, message, work) {
14532
+ const timer = new AbortController();
14533
+ const handle = setTimeout(() => {
14534
+ timer.abort(new DOMException(message, "TimeoutError"));
14535
+ }, REQUEST_TIMEOUT_MS$1);
14536
+ try {
14537
+ return await work(AbortSignal.any([signal, timer.signal]));
14538
+ } catch (cause) {
14539
+ if (timer.signal.aborted && !signal.aborted) throw new AdapterError("transient", message, { cause });
14540
+ throw cause;
14541
+ } finally {
14542
+ clearTimeout(handle);
14543
+ }
14544
+ }
14525
14545
  //#endregion
14526
14546
  //#region ../adapters/src/github/client.ts
14527
14547
  const MALFORMED$3 = "Malformed GitHub response";
@@ -14595,36 +14615,42 @@ var GithubClient = class {
14595
14615
  this.fetcher = fetcher;
14596
14616
  }
14597
14617
  async query(query, variables, signal) {
14598
- let response;
14599
- try {
14600
- response = await this.fetcher("https://api.github.com/graphql", {
14601
- method: "POST",
14602
- signal,
14603
- headers: {
14604
- authorization: `Bearer ${this.token}`,
14605
- "content-type": "application/json",
14606
- accept: "application/vnd.github+json"
14607
- },
14608
- body: JSON.stringify({
14609
- query,
14610
- variables
14611
- })
14612
- });
14613
- } catch (cause) {
14614
- if (signal.aborted) throw cause;
14615
- throw new AdapterError("transient", "GitHub request failed", { cause });
14616
- }
14617
- if (!response.ok) throw classifyHttpFailure({
14618
- status: response.status,
14619
- headers: response.headers,
14620
- body: await response.text()
14621
- }, this.now());
14622
- let body;
14623
- try {
14624
- body = await response.json();
14625
- } catch (cause) {
14626
- throw new AdapterError("transient", MALFORMED$3, { cause });
14627
- }
14618
+ const { response, body } = await withTimeout(signal, "GitHub request timed out", async (timed) => {
14619
+ let response;
14620
+ try {
14621
+ response = await this.fetcher("https://api.github.com/graphql", {
14622
+ method: "POST",
14623
+ signal: timed,
14624
+ headers: {
14625
+ authorization: `Bearer ${this.token}`,
14626
+ "content-type": "application/json",
14627
+ accept: "application/vnd.github+json"
14628
+ },
14629
+ body: JSON.stringify({
14630
+ query,
14631
+ variables
14632
+ })
14633
+ });
14634
+ } catch (cause) {
14635
+ if (timed.aborted) throw cause;
14636
+ throw new AdapterError("transient", "GitHub request failed", { cause });
14637
+ }
14638
+ if (!response.ok) throw classifyHttpFailure({
14639
+ status: response.status,
14640
+ headers: response.headers,
14641
+ body: await response.text()
14642
+ }, this.now());
14643
+ let body;
14644
+ try {
14645
+ body = await response.json();
14646
+ } catch (cause) {
14647
+ throw new AdapterError("transient", MALFORMED$3, { cause });
14648
+ }
14649
+ return {
14650
+ response,
14651
+ body
14652
+ };
14653
+ });
14628
14654
  const wire = parseWire(envelopeWire, body, MALFORMED$3);
14629
14655
  const errors = wire.errors ?? [];
14630
14656
  if (errors.some((error) => error.type === "RATE_LIMITED" || /rate limit/i.test(error.message))) throw classifyHttpFailure({
@@ -15517,38 +15543,40 @@ function createGithubIssuesAdapter(options) {
15517
15543
  if (!owner || !name) throw new AdapterError("config", "Invalid GitHub Issues repository");
15518
15544
  const root = `https://api.github.com/repos/${owner}/${name}`;
15519
15545
  async function request(url, signal) {
15520
- let response;
15521
- try {
15522
- response = await transport(url, {
15523
- signal,
15524
- headers: {
15525
- accept: "application/vnd.github+json",
15526
- authorization: `Bearer ${options.token}`,
15527
- "x-github-api-version": "2022-11-28"
15528
- }
15529
- });
15530
- } catch {
15531
- throw new AdapterError("transient", "GitHub issue request failed");
15532
- }
15533
- if (!response.ok) {
15534
- const failure = classifyHttpFailure({
15535
- status: response.status,
15536
- headers: response.headers,
15537
- body: await response.text()
15538
- }, options.now());
15539
- throw new GithubIssuesHttpError(response.status, failure);
15540
- }
15541
- let value;
15542
- try {
15543
- value = await response.json();
15544
- } catch {
15545
- throw new AdapterError("transient", "Malformed GitHub issue response");
15546
- }
15547
- const next = response.headers.get("link")?.match(/<([^>]+)>;\s*rel="next"/)?.[1];
15548
- return {
15549
- value,
15550
- ...next === void 0 ? {} : { next }
15551
- };
15546
+ return withTimeout(signal, "GitHub issue request timed out", async (timed) => {
15547
+ let response;
15548
+ try {
15549
+ response = await transport(url, {
15550
+ signal: timed,
15551
+ headers: {
15552
+ accept: "application/vnd.github+json",
15553
+ authorization: `Bearer ${options.token}`,
15554
+ "x-github-api-version": "2022-11-28"
15555
+ }
15556
+ });
15557
+ } catch {
15558
+ throw new AdapterError("transient", "GitHub issue request failed");
15559
+ }
15560
+ if (!response.ok) {
15561
+ const failure = classifyHttpFailure({
15562
+ status: response.status,
15563
+ headers: response.headers,
15564
+ body: await response.text()
15565
+ }, options.now());
15566
+ throw new GithubIssuesHttpError(response.status, failure);
15567
+ }
15568
+ let value;
15569
+ try {
15570
+ value = await response.json();
15571
+ } catch {
15572
+ throw new AdapterError("transient", "Malformed GitHub issue response");
15573
+ }
15574
+ const next = response.headers.get("link")?.match(/<([^>]+)>;\s*rel="next"/)?.[1];
15575
+ return {
15576
+ value,
15577
+ ...next === void 0 ? {} : { next }
15578
+ };
15579
+ });
15552
15580
  }
15553
15581
  let repositoryId;
15554
15582
  /** Rejects a next link outside this repository before any request goes to it. */
@@ -15803,32 +15831,34 @@ function createJiraAdapter(options) {
15803
15831
  const transport = options.fetch ?? fetch;
15804
15832
  const authorization = `Basic ${Buffer.from(`${options.credentials.email}:${options.credentials.token}`).toString("base64")}`;
15805
15833
  async function request(baseUrl, path, signal, body) {
15806
- let response;
15807
- try {
15808
- response = await transport(new URL(path, baseUrl), {
15809
- method: body === void 0 ? "GET" : "POST",
15810
- headers: {
15811
- Accept: "application/json",
15812
- Authorization: authorization,
15813
- ...body === void 0 ? {} : { "Content-Type": "application/json" }
15814
- },
15815
- ...body === void 0 ? {} : { body: JSON.stringify(body) },
15816
- signal
15817
- });
15818
- } catch {
15819
- if (signal.aborted) throw new AdapterError("transient", "Jira poll aborted");
15820
- throw new AdapterError("transient", "Jira request failed");
15821
- }
15822
- if (response.status === 414 && options.searchMethod === "GET") throw new AdapterError("config", "Jira GET search URL is too long");
15823
- if (!response.ok) throw new JiraHttpError(response.status, classifyHttpFailure({
15824
- status: response.status,
15825
- headers: response.headers
15826
- }, options.now()));
15827
- try {
15828
- return await response.json();
15829
- } catch {
15830
- throw new AdapterError("transient", INVALID);
15831
- }
15834
+ return withTimeout(signal, "Jira request timed out", async (timed) => {
15835
+ let response;
15836
+ try {
15837
+ response = await transport(new URL(path, baseUrl), {
15838
+ method: body === void 0 ? "GET" : "POST",
15839
+ headers: {
15840
+ Accept: "application/json",
15841
+ Authorization: authorization,
15842
+ ...body === void 0 ? {} : { "Content-Type": "application/json" }
15843
+ },
15844
+ ...body === void 0 ? {} : { body: JSON.stringify(body) },
15845
+ signal: timed
15846
+ });
15847
+ } catch {
15848
+ if (timed.aborted) throw new AdapterError("transient", "Jira poll aborted");
15849
+ throw new AdapterError("transient", "Jira request failed");
15850
+ }
15851
+ if (response.status === 414 && options.searchMethod === "GET") throw new AdapterError("config", "Jira GET search URL is too long");
15852
+ if (!response.ok) throw new JiraHttpError(response.status, classifyHttpFailure({
15853
+ status: response.status,
15854
+ headers: response.headers
15855
+ }, options.now()));
15856
+ try {
15857
+ return await response.json();
15858
+ } catch {
15859
+ throw new AdapterError("transient", INVALID);
15860
+ }
15861
+ });
15832
15862
  }
15833
15863
  async function validate(tracker, signal) {
15834
15864
  if (tracker.projectKeys.length === 0) throw new AdapterError("config", "Jira project key is required");
@@ -16131,6 +16161,8 @@ function applyEntityOutcomes(input) {
16131
16161
  }
16132
16162
  //#endregion
16133
16163
  //#region ../adapters/src/runner/runner.ts
16164
+ /** The setTimeout limit: a longer delay would otherwise fire after 1 ms. */
16165
+ const MAX_TIMER_MS = 2147483647;
16134
16166
  function startRunner(options) {
16135
16167
  const startedAt = options.now();
16136
16168
  const sources = options.entries.map((entry) => runSource(entry, options, startedAt));
@@ -16256,7 +16288,7 @@ function runSource(entry, options, runnerStartMs) {
16256
16288
  pollTimer = setTimeout(() => {
16257
16289
  pollTimer = void 0;
16258
16290
  run(poll);
16259
- }, delayMs);
16291
+ }, Math.min(delayMs, MAX_TIMER_MS));
16260
16292
  }
16261
16293
  async function poll() {
16262
16294
  if (stopping) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spur-board",
3
- "version": "0.38.0",
3
+ "version": "0.38.1",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": "^24.12.0 || ^26.0.0"