Skip to content

workflow web crashes on unmatched routes (e.g. /robots.txt, /favicon.ico) #1556

@lamualfa

Description

@lamualfa

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

  1. Don't use process.exit(1) in the catch handler for request-level errors - The catch handler should only call process.exit(1) for startup errors, not for errors that occur during request handling.

  2. Add error handling middleware to the Express app in @workflow/web/server - Add an Express error handler that catches ErrorResponseImpl with internal: true and returns a proper 404 response instead of letting the error propagate.

  3. Add a catch-all route or static file fallback before the React Router handler to serve common static files like /robots.txt and /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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions