vite icon indicating copy to clipboard operation
vite copied to clipboard

fix: clarify HTTP/2 handler type and sort imports

Open KirtiGautam620 opened this issue 3 weeks ago • 1 comments

Description

This PR resolves a lingering TypeScript issue in the HTTP server setup and improves code clarity.

Changes

Main Fix

  • packages/vite/src/node/http.ts: Replace @ts-expect-error TODO comment with explicit type cast (as any) and add explanatory comment documenting why this is valid
    • The Connect middleware app works as an HTTP/1.1 handler
    • With allowHTTP1: true, the HTTP/2 server correctly handles both HTTP/1.1 and HTTP/2 requests
    • This pattern is intentional and correct

Additional

  • Sort imports alphabetically in affected files for consistency with ESLint rules

Motivation

The original @ts-expect-error TODO: is this correct? comment indicated uncertainty about the type handling. This fix:

  • Clarifies the intent of the code
  • Documents the technical reasoning for maintainability
  • Provides clarity for future developers reading the code

Testing

  • Code passes pnpm run lint
  • Code passes pnpm run format
  • No runtime behavior changes

KirtiGautam620 avatar Dec 02 '25 17:12 KirtiGautam620

hii @sapphi-red, This PR replaces the @ts-expect-error with an explicit, documented type cast and explains why the HTTP/1.1 handler works correctly in the HTTP/2 server. It also includes minor import sorting. Please review when convenient—thanks!

KirtiGautam620 avatar Dec 02 '25 18:12 KirtiGautam620

https://github.com/vitejs/vite/pull/21135#issuecomment-3556411348

sapphi-red avatar Dec 03 '25 02:12 sapphi-red