Repository navigation
refactor(core): extract the serve request handler into its own module (AI-assisted) - #12865
Conversation
… (AI-assisted)
createServeRequestHandler({outDir, baseUrl, trailingSlash}) receives
explicit args instead of closing over serve() variables, so it can be
unit tested. The handler body is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Caution Review failedAn error occurred during the review process. Please try again later. Walkthrough
Merge Risk:
|
✅ [V2]
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Size Change: 0 B Total Size: 12.1 MB ℹ️ View Unchanged
|
|
Size Change: 0 B Total Size: 12.1 MB ℹ️ View Unchanged
|
⚡️ Lighthouse report for the deploy preview of this PR
|
Motivation
Extract the
docusaurus serverequest handler from theserve()closure intoserve/requestHandler.ts, so it can be unit tested.createServeRequestHandler({outDir, baseUrl, trailingSlash})receives explicit args instead of closing over theserve()variables. The handler body moves as is: same redirects, samebaseUrlrewrite, sameserve-handleroptions.The only code difference is that the handler is now
asyncand awaitsserveHandler(), so tests can observe its rejections. No behavior change in production: Node's HTTP server ignores the returned promise, so aserveHandler()rejection still reaches the CLI'sunhandledRejectionhandler, like the floating promise did before.This prepares #12858, which adds the
servetest suite.Test Plan
Ran the same matrix of 162 requests against
docusaurus servebuilt frommainand from this branch: 6baseUrl/trailingSlashconfigs × clean URLs,.html, folders, assets, query strings, encoded paths, paths outside thebaseUrl. The status,Locationand served file are identical, including the 4 encodedcaférequests that crash the server onmainwith the same error log.Test links
Deploy preview: https://deploy-preview-12865--docusaurus-2.netlify.app/
(AI-assisted)
🤖 Generated with Claude Code
Summary by CodeRabbit