Last 12 weeks ยท 0 commits
2 of 6 standards met
Summary The function tries first and falls back to for pattern matching. However, if the source pattern uses syntax that cannot parse (e.g. extglob negation like ), throws an exception instead of returning . This prevents the fallback from ever running. This PR wraps the block in a try/catch so that incompatible patterns gracefully fall through to , which does support them. The problem For a rewrite config like: 1. mangles the pattern into 2. tries to compile this and throws: 3. The exception propagates up โ (which handles this pattern correctly) is never called 4. The entire promise rejects This caused a production incident for us where the asset server silently failed to respond to any HTTP request, because the unhandled rejection meant no response was ever sent. The fix Wrap lines 46-56 in a try/catch. If throws, clear the keys array and fall through to the check on line 59, which is what the code already intends as a fallback. Tests Added an integration test that verifies a rewrite with an extglob negation pattern works correctly (previously this would have thrown). All 67 tests pass. Made with Cursor
Repository: vercel/serve-handler. Description: The foundation of `serve` Stars: 616, Forks: 105. Primary language: JavaScript. Languages: JavaScript (87.8%), EJS (12.2%). License: MIT. Homepage: https://npmjs.com/serve-handler Topics: handler, middleware, server, single-page-applications, static. Latest release: 6.1.6 (1y ago). Open PRs: 36, open issues: 48. Last activity: 1y ago. Community health: 50%. Top contributors: leo, AndyBitz, TooTallNate, dependabot[bot], thasophearak, wellingguzman, kachkaev, andyburke, AxlLind, balupton and others.
JavaScript
I think this is a regression, as it was added in https://github.com/vercel/serve-handler/pull/45, and there appears to be tests for it. If I try to launch with the following config: It fails with: