Skip to content

Comments

Refactor verify endpoint timeout handling and improve fetch robustness#3

Merged
GsCommand merged 1 commit intomainfrom
claude/review-runtime-repo-oDcvb
Feb 15, 2026
Merged

Refactor verify endpoint timeout handling and improve fetch robustness#3
GsCommand merged 1 commit intomainfrom
claude/review-runtime-repo-oDcvb

Conversation

@GsCommand
Copy link
Contributor

Summary

This PR refactors the /verify endpoint to use explicit timeout guards instead of Promise.race(), improves doFetch() body handling with a fallback for runtimes lacking getReader(), and adds security/operational documentation.

Key Changes

Core Logic Improvements

  • Verify endpoint timeout handling: Replaced Promise.race() pattern with a setTimeout guard and responded flag to prevent double-response races. The timeout now fires independently and guards all response paths (success, error, and schema validation).

  • Fetch body handling: Added fallback logic in doFetch() for runtimes where resp.body.getReader() is unavailable. Falls back to resp.text() when streaming is not supported, ensuring consistent behavior across environments.

  • Simplified buffer concatenation: Removed conditional logic that fell back to resp.text() after streaming; now always uses Buffer.concat() on the collected chunks.

Documentation & Configuration

  • Added SECURITY.md: Vulnerability reporting policy, supported versions, and hardening guidance (key protection, debug route gating, CORS restriction, SSRF guard, HTTPS, dependency pinning).

  • Added LICENSE: MIT license matching protocol-commons.

  • Updated package.json: Added description, license field, repository metadata, and Node.js engine requirement (>=20.0.0).

  • Updated REVIEW.md: Converted from risk-focused to resolution-focused format, documenting all prior issues now addressed (CORS, debug routes, request validation, double-response race, fetch body consumption).

  • Enhanced CI workflow: Added branch filters and npm audit check for high-severity vulnerabilities.

  • Fixed .gitignore: Removed overly broad *.json rule that blocked package.json tracking; now only ignores node_modules/.

Implementation Details

  • The verify endpoint now uses a top-level setTimeout that fires after VERIFY_MAX_MS, setting responded = true and sending a 500 error if no response has been sent yet.
  • A send() helper clears the timer and checks the responded flag before sending, ensuring only one response is ever sent.
  • The fail() helper now calls send() instead of directly calling res.status().json().
  • Fetch fallback gracefully handles both streaming and non-streaming response bodies, maintaining byte-limit enforcement in both paths.

https://claude.ai/code/session_01Jh9WXqejeBVXesWCkpt9an

- Fix verify endpoint double-response race condition (responded guard)
- Fix doFetch body double-consumption when reader exists
- Fix .gitignore blocking *.json (was hiding package.json changes)
- Add MIT LICENSE matching protocol-commons
- Add SECURITY.md with vulnerability reporting policy
- Add npm audit step to CI, scope triggers to main branch
- Add package.json metadata (description, license, repository, engines)
- Patch qs high-severity vulnerability via npm audit fix
- Update docs/REVIEW.md to reflect all resolved issues

https://claude.ai/code/session_01Jh9WXqejeBVXesWCkpt9an
@GsCommand GsCommand merged commit 0636e7c into main Feb 15, 2026
1 check passed
@GsCommand GsCommand deleted the claude/review-runtime-repo-oDcvb branch February 15, 2026 23:53
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.

2 participants