Skip to content

Add preconnect() to reduce TLS handshake latency#294

Draft
luismeyer wants to merge 1 commit intomainfrom
luismeyer/preconnect-flags
Draft

Add preconnect() to reduce TLS handshake latency#294
luismeyer wants to merge 1 commit intomainfrom
luismeyer/preconnect-flags

Conversation

@luismeyer
Copy link
Member

Summary

Adds a preconnect() method to FlagNetworkDataSource that fires a lightweight HEAD request during construction to warm the connection pool for flags.vercel.com, eliminating the DNS+TCP+TLS handshake overhead on subsequent requests.

Changes

  • Source: Added private preconnect() method that fires a fire-and-forget HEAD request with proper Authorization and User-Agent headers
  • Tests: Added 4 comprehensive tests covering correct header propagation, build-step skipping, custom fetch usage, and graceful failure handling
  • Verification: All 312 tests pass, type check passes

Test Plan

  • All existing tests continue to pass (312 tests)
  • New preconnect tests verify all documented behavior
  • Type checking passes with no issues
  • HEAD request handler added to test setup to prevent MSW warnings

🤖 Generated with Claude Code

Fire a lightweight HEAD request to flags.vercel.com during constructor to warm the connection pool, skipping the full DNS+TCP+TLS handshake on subsequent requests. Includes tests verifying correct headers, build-step skipping, custom fetch usage, and graceful failure handling.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@vercel
Copy link
Contributor

vercel bot commented Mar 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
shirt-shop Ready Ready Preview, Comment Mar 2, 2026 3:21pm
shirt-shop-api Ready Ready Preview, Comment Mar 2, 2026 3:21pm

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