-
Notifications
You must be signed in to change notification settings - Fork 221
workflow web crashes on unmatched routes (e.g. /robots.txt, /favicon.ico) #1556
Description
Bug Description
When running workflow web, the process crashes (exits with code 1) when any request hits a URL that doesn't match a React Router route (e.g. /robots.txt, /favicon.ico, /sitemap.xml).
Root Cause
The oclif Web command class has a catch handler that calls process.exit(1) on any error:
https://github.com/vercel/workflow/blob/main/packages/cli/src/commands/web.ts#L29
When a browser or bot requests a static file like /robots.txt, the React Router SSR handler (via @react-router/express) encounters a "No route matches" error. This error gets logged and can propagate through the error handling chain, eventually triggering the oclif catch handler which calls process.exit(1).
Error Output
Error: No route matches URL "/robots.txt"
at getInternalRouterError (...)
at Object.query (...)
at handleDocumentRequest (...)
at requestHandler (...)
at requestHandler (...)
No routes matched location "/robots.txt"
ErrorResponseImpl {
status: 404,
statusText: 'Not Found',
internal: true,
data: 'Error: No route matches URL "/robots.txt"',
error: Error: No route matches URL "/robots.txt"
}
Expected Behavior
The server should handle unmatched routes gracefully by returning a 404 response without crashing.
Possible Fixes
-
Don't use
process.exit(1)in the catch handler for request-level errors - Thecatchhandler should only callprocess.exit(1)for startup errors, not for errors that occur during request handling. -
Add error handling middleware to the Express app in
@workflow/web/server- Add an Express error handler that catchesErrorResponseImplwithinternal: trueand returns a proper 404 response instead of letting the error propagate. -
Add a catch-all route or static file fallback before the React Router handler to serve common static files like
/robots.txtand/favicon.ico.
Environment
workflow: 4.2.0-beta.67@workflow/web: 4.1.0-beta.39@workflow/cli: 4.2.0-beta.73- Node.js: 24
- OS: Linux