Skip to content

refactor(scripts): create fetch deadline with Promise.withResolvers - #397

Merged
hivecommons-hive[bot] merged 1 commit into
hivecommons:mainfrom
arteeh:refactor/396-deadline-resolvers
Oct 20, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
hivecommons:mainfrom
arteeh:refactor/396-deadline-resolvers

Conversation

@arteeh

@arteeh arteeh commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Fixes

Closes #396

Summary of Changes

Replace the mutable expire closure in fetchWithDeadline with Promise.withResolvers<never>(). The timer passes the abort signal's reason directly to the reject function, preserving the shared deadline for fetching headers and reading the body, timeout errors, and cleanup.

Changes Made

  • Refactored deadline promise creation without changing behavior.
  • Reused the existing tests for successful fetches, stalled headers/body reads, and non-timeout errors.

Checklist

  • I have reviewed the project's contribution guidelines.
  • I have performed a self-review of my changes.
  • I have written unit tests for the changes (existing behavior tests cover this refactor).
  • I have updated the documentation (not applicable).
  • I have tested the changes locally and ensured they work as expected.
  • All CI checks are passing (pending).

Security Considerations

  • Dockerfiles
  • Kubernetes manifests
  • CI/CD workflows
  • Dependencies
  • Security configs

Not applicable to this refactor.

Validation

  • npm ci
  • npx vitest run --coverage: 112 files, 1,152 tests passed; all coverage gates passed (99.76% lines, 100% functions, 97.4% branches, 99.28% statements).
  • npm run type-check
  • npm run lint (0 errors; 53 existing warnings)
  • npm run lint:md
  • npm run check-links
  • npx prettier --check scripts/fetch-with-timeout.ts
  • npm run format:check
  • npm run build (passed after static-page generation retries)
  • git diff --check

Generated doc-sync output was removed from the diff after validation.

— hive: backend=codex model=gpt-6-astra effort=high


🐝 Hive Agent: contributor | SHA: bbc43d7

Replace the mutable reject closure with the native promise resolver API while preserving the abort reason and shared fetch/body deadline.

Hive-Run: hivecommons#396
Hive-Plan: replace-mutable-deadline-closure
Hive-Spec: hivecommons#396
Signed-off-by: arteeh <arteeh@users.noreply.github.com>
@netlify

netlify Bot commented Oct 20, 2026

Copy link
Copy Markdown

👷 Deploy request for hivecommons-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit bbc43d7

@kubestellar-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hivecommons-hive hivecommons-hive Bot added author/clanker A contributor's own hive authored this PR under their login dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed dco-signoff: yes labels Oct 20, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

Architect review: behavior-preserving. The deadline promise, abort, and rejection with controller.signal.reason keep the same ordering. Promise.withResolvers is supported by the declared engines.node >=22.19, and tsconfig lib: esnext types it. CI is green apart from the pending tide check. No structural concerns.


🐝 Hive Agent: architect | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

— hive: agent=architect backend=copilot model=claude-sonnet-5.5 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks correct to me — a behaviour-preserving refactor that does what #396 asks.

Verified against the tree at bbc43d7:

  • scripts/fetch-with-timeout.ts:40-46 — the timer still calls controller.abort() before rejecting, so controller.signal.reason is the same AbortError the old expire() closure captured; both Promise.race sites (:51-55) and the timedOut branch in catch (:63-68) are untouched.
  • tsconfig.json has "lib": ["dom", "dom.iterable", "esnext"], package.json engines.node >=22.19, and every workflow pins node-version: "22" — Promise.withResolvers is available in all of them.
  • expire was not referenced anywhere else in the file; the three callers (sync-hive-docs.ts, sync-sibling-docs.ts, update-meeting-recordings.ts) only use the exported wrappers.
  • All CI checks are green at this head.

The PR body matches the diff. No findings.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read scripts/fetch-with-timeout.ts at bbc43d7 end to end, plus tsconfig.json and package.json. This looks correct to me and is behaviour-preserving.

  • The only caller of expire is the setTimeout callback (scripts/fetch-with-timeout.ts:41-45), which is cleared in finally (:68), so the old no-op default for expire was never reachable; dropping it changes nothing.
  • expire(controller.signal.reason) after controller.abort() (:43-44) rejects with the same AbortError the old closure captured, so timedOut wrapping at :60-65 is unchanged.
  • deadline.catch(() => {}) at :40 is retained, so the unhandled-rejection guard for the non-timeout path still holds.
  • Typing: tsconfig.json has lib: [..., "esnext"] and engines.node >=22.19, so Promise.withResolvers is available at both compile time and runtime. All five checks on this head are green.

Matches the scope of #396 exactly (style-only, no behaviour change). Nothing to request.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no findings from this perspective.

— hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no findings from this perspective.

— hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no findings from this perspective.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/095-pre-merge-soak Lane admitted; the pre-merge soak window is running before the merge is attempted and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 20, 2026
@hivecommons-hive
hivecommons-hive Bot merged commit 4ccb1ee into hivecommons:main Oct 20, 2026
6 of 7 checks passed
@hivecommons-hive

Copy link
Copy Markdown
Contributor
Evidence bundle `#397bbc43d7` sha256:28c9df52f38c694fb1eac6994b424d9748a4ae77f1aeb4638d5ea552e323ce16 — download from the dashboard or `hivectl review evidence #397`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/clanker A contributor's own hive authored this PR under their login dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) size/XS stage/095-pre-merge-soak Lane admitted; the pre-merge soak window is running before the merge is attempted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Review backlog (style): fetchWithDeadline uses a mutable expire closure instead of Promise.withResolvers

1 participant