Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: send 405 not 500 for missing action and surface in CatchBoundary #2342

Merged
merged 10 commits into from Mar 21, 2022

Conversation

jacob-ebey
Copy link
Member

@jacob-ebey jacob-ebey commented Mar 16, 2022

This really boils down to we need to treat caught action submissions as "successful" and still load data for the new location, filtering out routes at and below the boundary, passing through the boundary ID's for retention in the state after the loads complete.

I've updated the action submission navigation codepath first to verify, but I also need to update the fetcher codepath if this pans out.

Closes: #111

  • Docs
  • Tests

fix: load module after action submission if it's not a redirect
fix: when an action "catches", still load next data for next location to render nested boundaries and not be missing parent data
@jacob-ebey jacob-ebey changed the title Jacob/rem 877 send 405 not 500 for missing action feat: send 405 not 500 for missing action and surface in CatchBoundary Mar 16, 2022
`to submit to it. To fix this, please add an \`action\` function to the route`
);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a way to do this in dev only? I don't want bots POSTing all over the place making a mess of our logs. I think I'd rather just not even have this I think if we don't have a way to branch in dev vs. prod.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a log that occurs only in the browser on client transitions, I'm not sure most bots are smart enough to be able to trigger this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also surface this message in the catch boundary data, but it would be the first case where the framework lands you there with data of its own. Would also mean you'd have to handle a data case that you did not throw yourself and I'm not a fan of having to have that knowledge.

@jacob-ebey jacob-ebey changed the title feat: send 405 not 500 for missing action and surface in CatchBoundary work in progress: send 405 not 500 for missing action and surface in CatchBoundary Mar 16, 2022
@jacob-ebey jacob-ebey changed the title work in progress: send 405 not 500 for missing action and surface in CatchBoundary feat: send 405 not 500 for missing action and surface in CatchBoundary Mar 18, 2022
@jacob-ebey jacob-ebey merged commit b00fe18 into dev Mar 21, 2022
@jacob-ebey jacob-ebey deleted the jacob/rem-877-send-405-not-500-for-missing-action branch March 21, 2022 05:07
MichaelDeBoey pushed a commit to TheRealAstoo/remix that referenced this pull request Mar 21, 2022
remix-run#2342)

fix: load module after action submission if it's not a redirect
fix: when an action "catches", still load next data for next location to render nested boundaries and not be missing parent data
F3n67u pushed a commit to F3n67u/remix that referenced this pull request Mar 23, 2022
remix-run#2342)

fix: load module after action submission if it's not a redirect
fix: when an action "catches", still load next data for next location to render nested boundaries and not be missing parent data
brophdawg11 added a commit to remix-run/react-router that referenced this pull request Apr 6, 2022
This matches the behavior added to Remix in remix-run/remix#2342
brophdawg11 added a commit to remix-run/react-router that referenced this pull request Apr 13, 2022
This matches the behavior added to Remix in remix-run/remix#2342
ryanflorence pushed a commit to remix-run/react-router that referenced this pull request May 19, 2022
This matches the behavior added to Remix in remix-run/remix#2342
brophdawg11 added a commit to remix-run/react-router that referenced this pull request Jun 6, 2022
* feat: add history package and createMemoryHistory implementation (#8702)

* feat: add initial empty history package

* feat: add createMemoryHistory + tests

* chore: add rollup buld for history

* chore: change state type from unknown -> any

* feat: Change listen interface to be pop only

* chore: fix lint warning

* Add history package to yarn workspace

* chore: Address PR feedback

* feat: Add remix-router package and loader functionality

Additional notes:
 - adds unique route id generation to react-router
 - enhances test harness to manage at navigation level
 - combines error/catch into a single exception

* feat: add support for submissions

* chore: code organization + cleanup

* ci: copy over unit test from transition manager

* fix: Fix action arguments bug

* feat: add createBrowserHistory and createHashHistory

* chore: rename package to @remix-run/router

* wip: initial router integration with React

* wip: add userLoaderData

* Remove history package and move history.ts into router

* fix: fix URLSearchParams keys typescript error

This one was tricky:
 - react-router-native used to find the type for URLSearchParams from @types/react-native
 - The new history work added @types/jsdom
 - react-router-native now finds that URLSearchParams before the @types/react-native one
 - the jsdom one imports from the internal built-in TS DOM lib
 - but it does not include the DOM.Iterable values such as keys

See: microsoft/TypeScript#38139

* feat: add data loading/rendering APIs

 - loader/action
 - useLoaderData/useActionData/useTransition
 - exceptionElement/useRouteException
 - fallbackElement

* feat: add browser/hash routers and bring over useSubmit

* feat: bring <Form> to react router-dom

* feat: support redirects returned from loaders

* feat: Support basename in data routers

* chore: remove backup _components file

* chore: extract dom.ts utils file

* feat: add <Route shouldReload> and fix bug in shouldReload logic

* chore: convert to router.subscribe for easier useSyncExternalStore usage

* chore: switch to babel-jest TS transform instead of ts-jest

* fix: make route id optional for backwards compatibility

* feat: default fallbackElement/exceptionElement + add useMacthes/useRouteData

* fix: Fix up build issues with v5-compat

* chore: renames and feedback cleanup

* feat: handle render errors through exceptionElement

* feat: move initial data load into router

* chore: do not handle exceptions for non-data-routers

* chore: remove historyv5 dependency

* feat: add support for router.revalidate()

* feat: add useRevalidator() hook

* fix: fix shouldReload support for revalidate()

* fix: handle 405 action responses correctly

This matches the behavior added to Remix in remix-run/remix#2342

* feat: handle X-Remix-Revalidate hesders returned from loader redirects

This ports over the remix behavior from remix-run/remix#2370

* chore: PR feedback

* chore: copy transition fetcher tests verbatim

* feat: add support for fetchers

* feat: add useFetcher

* ci: add tests for useFetcher/useFetchers

* chore: add formAction to submission

* chore: remove basename from data routers

* chore: change shouldReload url type

* chore: change default fallback element

* chore: add tests for cleanup and make Router type explicit

* feat: support returning responses from loaders/actions

automatically parses the response body with json() or text() depending on the content type of the response. This makes it really convenient to use `fetch` and brings the server semantics to client loaders like `json(data)` or `new Response(“”, { status: 404 })` etc.

* chore: cleanup auto-unwrap logic, add action info to request, remove action submission fields

* feat: provide full control to users in shouldRevalidate

* chore: remove hashchange and create createUrlBasedHistory abstraction

* fix: handle syncronous initial load

* fix request patch

* feat: support fetcher opt-in revalidation

* ci: clean up revalidating fetcher tests and logic

* feat: wiure up useFetcher and turn off revalidation on submit

* docs: update transition/fetcher diagrams

* ci: bump bundle thresholds for new data routing

* chore: update to latest @web-std/fetch with proper formData handling

Our PR was merged and released in 4.1.0 so we can remove our local override.
See: web-std/io#60

* feat: move to better cross-browser fallback spinner

* Revert "feat: move to better cross-browser fallback spinner"

This reverts commit a887019.

* chore: Rename "exception" to "error"

Done in steps via grep/sed:
 - exceptionElement -> errorElement
 - useRouteException -> useRouteError
 - Exception -> Error
 - exceptions -> errors
 - exception -> error

* feat: handle revalidation for interrupted submissions

feat: change defaultShouldRevalidate from funciton -> boolean
chore: simplify revalidation via isRevalidationRequired

* feat: opt-in fetcher.load to revalidation by default

* feat: send actionResult to shouldRevalidate

* feat: add <ScrollRestoration> component and <Link resetScroll=false>

* chore: rename navigation -> transition

* feat: flatten submission onto shouldRevalidate

* feat: simplify form submit logic via event.submitter

Copies the changes from remix remix-run/remix#3094

* chore: clean up types

* chore: sync up react-router-native public api

* feat: properly support React 18 + React.StrictMode

* chore: fix lint warnings

* chore: remove default fallback element

* chore: add @remix-run/router to example vite configs for USE_SOURCE

* chore: add data-router and scroll-restoration examples

* chore: switch from @web-std/fetch to @remix-run/web-fetch for tests

* feat: add pending logic to NavLink (#8875)

* feat: add pending logic to NavLink

* chore: fixup type imports

* chore: add useMemo to nextMatch calculation

* chore: inline react use-sync-external-store/shim for UMD builds

* chore: clean up some exports and add some jsdocs

* feat: add DataStaticRouter for SSR

* chore: fix link

* fix: default replace=false only for GET submissions

* chore: update scroll restoration example to include data loading

* feat: remove fetcher.type since it can be derived

* feat: Remove promise from return signature of router methods

* chore: remove encType from Form props

* WIP docs

* feat: auto-unwrap error Responses into ErrorResponse

* chore: add error boundary example

* feat: support routes prop on data routers

* docs: moar docs

* chore: remove navigation.type

* docs docs docs

* dooooooooooooooooooocs

* docs: fix contributing link (#8885)

* docs: fix contributing link

* chore: add alexlbr to contributors

* Docs: Fix typo in getting-started > concepts (#8888)

* docs: fix small typo in getting-started > concepts

* Sign CLA: add tanayv to contributors.yml

* chore: sort contributors list

* docs: think it’s ready for the big time

* docs: notes demo

* Update overview.md (#8892)

* Update overview.md

* Update contributors.yml

* Version 6.4.0-pre.0

* docs: link fixes

* chore: publish @remix-run/router

* Version 6.4.0-pre.1

* chore: publish @remix-run/router

* Version 6.4.0-pre.2

* docs: DataStaticRouter stub

* docs: not sure what this was 😂

* docs: link to the demo

* fix: properly handle 404s using error boundaries

* docs: getting started installation

* Convert formMethod=GET to be a loading navigation instead of submitting

* Handle invalid GET formData via 400 Bad Request error

* fix: Properly handle descendent routes within a data router

* docs: update useMatches and useNavigation docs

* fix: better solution for 404 error boundaries

* chore: refactor resetScroll to avoid history state mutation

* docs: add note on useMatches and descendent routes

* chore: move newly added resolveTo test from react-router to router

* ci: Remove website workflow before merging remixing work into dev

Co-authored-by: Ryan Florence <rpflorence@gmail.com>
Co-authored-by: Alex Lobera <alex.lobera@gmail.com>
Co-authored-by: Tanay Vardhan <tvardha2@illinois.edu>
Co-authored-by: remix-cla-bot[bot] <92060565+remix-cla-bot[bot]@users.noreply.github.com>
Co-authored-by: Michal Petrik <misopetrik@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants