Skip to content

feat(did): add optional fetch timeout to the did:web resolver#129

Open
EfeDurmaz16 wants to merge 1 commit into
agentcommercekit:mainfrom
EfeDurmaz16:did-resolver-fetch-timeout
Open

feat(did): add optional fetch timeout to the did:web resolver#129
EfeDurmaz16 wants to merge 1 commit into
agentcommercekit:mainfrom
EfeDurmaz16:did-resolver-fetch-timeout

Conversation

@EfeDurmaz16

@EfeDurmaz16 EfeDurmaz16 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

What

Adds an optional timeout (ms) to DidWebResolverOptions / getResolver for
the did:web resolver. When set, the resolver passes
AbortSignal.timeout(timeout) to the underlying fetch.

Why

Resolving a did:web DID fetches the host named in the DID. Today
fetchDidDocumentAtUrl calls fetch(url, { mode: "cors" }) with no
AbortSignal, so an unresponsive or slow host hangs the resolver
indefinitely. The resolver's own header comment says it exists for "additional
checks and more control for fetching and resolution", so a bounded fetch fits
its purpose. This is resource-exhaustion hardening, not an SSRF fix (did:web
inherently fetches the domain named in the DID).

Change

  • timeout?: number on DidWebResolverOptions
  • threaded through getResolver -> resolve -> fetchDidDocumentAtUrl
  • omitted = no timeout, so existing behaviour is unchanged (backward compatible)

Tests

Three new tests in web-did-resolver.test.ts: the resolver builds the signal
from the configured timeout (AbortSignal.timeout is called with the value),
passes no signal when the option is omitted, and surfaces an aborted/timed-out
fetch as the standard notFound resolution error.
pnpm --filter @agentcommercekit/did test -> 73 passing. Changeset included
(minor). A response-size cap is a natural follow-up but needs body streaming,
so it is out of scope here.

AI assistance disclosure

Per the repository AI policy: implemented and tested by gpt 5.6-sol and fable 5, then reviewed and understood by me. I can explain the implementation and its trade-offs without AI aid. Tests, typecheck, and formatting pass locally against the package suite.

Summary by CodeRabbit

  • New Features
    • Added an optional timeout setting for did:web resolution requests.
    • Requests can now be automatically cancelled when hosts are slow or unresponsive.
    • Timeout failures return a clear “not found” resolution result with error details.
    • When no timeout is configured, existing fetch behavior remains unchanged.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@EfeDurmaz16, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 52 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ce02d1b1-dfff-4f97-bedf-dfeb7f12adc2

📥 Commits

Reviewing files that changed from the base of the PR and between 7503cd5 and f288d45.

📒 Files selected for processing (3)
  • .changeset/did-web-resolver-fetch-timeout.md
  • packages/did/src/did-resolvers/web-did-resolver.test.ts
  • packages/did/src/did-resolvers/web-did-resolver.ts

Walkthrough

Changes

did:web fetch timeout

Layer / File(s) Summary
Configure and apply fetch timeout
packages/did/src/did-resolvers/web-did-resolver.ts
Adds an optional timeout setting and passes AbortSignal.timeout(timeout) to the DID document fetch when configured.
Validate timeout behavior and document option
packages/did/src/did-resolvers/web-did-resolver.test.ts, .changeset/did-web-resolver-fetch-timeout.md
Tests configured, omitted, and rejected timeout requests; documents the new option and preserved default behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: venables

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding an optional fetch timeout to the did:web resolver.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/did/src/did-resolvers/web-did-resolver.ts`:
- Around line 70-78: Update getResolver() to validate timeout before calling
AbortSignal.timeout(), rejecting negative, non-integer, non-finite, and
non-number values explicitly rather than allowing them to become notFound DID
errors. Preserve valid timeout behavior and add tests covering each
invalid-value category.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8a295354-8cf0-4ada-af59-bed6ec27927b

📥 Commits

Reviewing files that changed from the base of the PR and between 43a066c and 7503cd5.

📒 Files selected for processing (3)
  • .changeset/did-web-resolver-fetch-timeout.md
  • packages/did/src/did-resolvers/web-did-resolver.test.ts
  • packages/did/src/did-resolvers/web-did-resolver.ts

Comment thread packages/did/src/did-resolvers/web-did-resolver.ts
@EfeDurmaz16
EfeDurmaz16 force-pushed the did-resolver-fetch-timeout branch from 7503cd5 to f288d45 Compare July 22, 2026 00:31
@EfeDurmaz16

Copy link
Copy Markdown
Contributor Author

@venables when you have a moment, would appreciate a review. Small backward-compatible hardening (optional fetch timeout on the did:web resolver) I hit while building an ACK-ID + x402 demo. CodeRabbit's note is addressed; CI is waiting on a maintainer 'approve and run' for the fork branch.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant