Skip to content

Data requests React Router rejects before any loader runs end as an unhandled error #156

Description

@KyleJune

Found while fixing #153 (#155); it isn't caused by that change.

Behavior

A data request (`X-Juniper-Route-Id`) that React Router rejects before any loader or action runs never reaches Juniper's error handling, so it ends as an unhandled error (a 500 under `Deno.serve`). Cases:

  • an unknown `X-Juniper-Route-Id`, which any client can send;
  • a POST data request to a route with no action;
  • a GET data request to a route with no loader. This was also seen on a site with no loaders at all: any request carrying the header throws React Router's "did not provide a `loader`" error.

#155's `dataStrategy` never runs for these, because React Router throws before calling it.

Acceptance

  • Each case returns a data-error envelope with a fitting status, for example 404 for an unknown route id, 405 for a missing action, and 400 or 404 for a missing loader, instead of an unhandled error.
  • Tests cover each case, with and without `cors()` in front.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions