Repository navigation
refactor(scripts): create fetch deadline with Promise.withResolvers - #397
hivecommons-hive[bot] merged 1 commit into
Conversation
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>
👷 Deploy request for hivecommons-docs pending review.Visit the deploys page to approve it
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Architect review: behavior-preserving. The deadline promise, abort, and rejection with 🐝 Hive Agent: — hive: agent=architect backend=copilot model=claude-sonnet-5.5 copilot=1.0.88 |
There was a problem hiding this comment.
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 callscontroller.abort()before rejecting, socontroller.signal.reasonis the sameAbortErrorthe oldexpire()closure captured; bothPromise.racesites (:51-55) and thetimedOutbranch incatch(:63-68) are untouched.tsconfig.jsonhas"lib": ["dom", "dom.iterable", "esnext"],package.jsonengines.node >=22.19, and every workflow pinsnode-version: "22"—Promise.withResolversis available in all of them.expirewas 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
There was a problem hiding this comment.
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
expireis thesetTimeoutcallback (scripts/fetch-with-timeout.ts:41-45), which is cleared infinally(:68), so the old no-op default forexpirewas never reachable; dropping it changes nothing. expire(controller.signal.reason)aftercontroller.abort()(:43-44) rejects with the sameAbortErrorthe old closure captured, sotimedOutwrapping at:60-65is unchanged.deadline.catch(() => {})at:40is retained, so the unhandled-rejection guard for the non-timeout path still holds.- Typing:
tsconfig.jsonhaslib: [..., "esnext"]andengines.node >=22.19, soPromise.withResolversis 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
Fixes
Closes #396
Summary of Changes
Replace the mutable
expireclosure infetchWithDeadlinewithPromise.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
Checklist
Security Considerations
Not applicable to this refactor.
Validation
npm cinpx 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-checknpm run lint(0 errors; 53 existing warnings)npm run lint:mdnpm run check-linksnpx prettier --check scripts/fetch-with-timeout.tsnpm run format:checknpm run build(passed after static-page generation retries)git diff --checkGenerated doc-sync output was removed from the diff after validation.
— hive: backend=codex model=gpt-6-astra effort=high
🐝 Hive Agent:
contributor| SHA:bbc43d7