Skip to content

Commit

Permalink
Add support for future.v3_throwAbortReason flag (#8251)
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 authored Jan 26, 2024
1 parent deaedf5 commit 4c627af
Show file tree
Hide file tree
Showing 14 changed files with 349 additions and 28 deletions.
6 changes: 6 additions & 0 deletions .changeset/throw-abort-reason.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@remix-run/dev": minor
"@remix-run/server-runtime": minor
---

Add `future.v3_throwAbortReason` flag to throw `request.signal.reason` when a request is aborted instead of an `Error` such as `new Error("query() call aborted: GET /path")`
3 changes: 3 additions & 0 deletions docs/file-conventions/remix-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ The `future` config lets you opt-into future breaking changes via [Future Flags]
- **`v3_fetcherPersist`**: Change fetcher persistence/cleanup behavior in 2 ways ([RFC][fetcherpersist-rfc]):
- Fetchers are no longer removed on unmount, and remain exposed via [`useFetchers`][use-fetchers] until they return to an `idle` state
- Fetchers that complete while still mounted no longer persist in [`useFetchers`][use-fetchers] since you can access those fetchers via [`useFetcher`][use-fetcher]
- **`v3_relativeSplatPath`**: Fixes buggy relative path resolution in splat routes. Please see the [React Router docs][relativesplatpath] for more information.
- **`v3_throwAbortReason`**: When a server-side request is aborted, Remix will throw the `request.signal.reason` instead of an error such as `new Error("query() call aborted...")`

## ignoredRouteFiles

Expand Down Expand Up @@ -276,3 +278,4 @@ There are a few conventions that Remix uses you should be aware of.
[fetcherpersist-rfc]: https://github.com/remix-run/remix/discussions/7698
[use-fetchers]: ../hooks/use-fetchers
[use-fetcher]: ../hooks/use-fetcher
[relativesplatpath]: https://reactrouter.com/en/main/hooks/use-resolved-path#splat-paths
4 changes: 2 additions & 2 deletions docs/future/vite.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ All other bundling-related options are now [configured with Vite][vite-config].
The following subset of Remix config options are supported:

- [appDirectory][app-directory]
- [future][future]
- [ignoredRouteFiles][ignored-route-files]
- [publicPath][public-path]
- [routes][routes]
Expand Down Expand Up @@ -1069,11 +1070,10 @@ Finally, we were inspired by how other frameworks implemented Vite support:
We're definitely late to the Vite party, but we're excited to be here now!

[vite]: https://vitejs.dev
[supported-with-some-deprecations]: #add-mdx-plugin
[template-vite-cloudflare]: https://github.com/remix-run/remix/tree/main/templates/unstable-vite-cloudflare
[remix-config]: ../file-conventions/remix-config
[app-directory]: ../file-conventions/remix-config#appdirectory
[assets-build-directory]: ../file-conventions/remix-config#assetsbuilddirectory
[future]: ../file-conventions/remix-config#future
[ignored-route-files]: ../file-conventions/remix-config#ignoredroutefiles
[public-path]: ../file-conventions/remix-config#publicpath
[routes]: ../file-conventions/remix-config#routes
Expand Down
1 change: 1 addition & 0 deletions packages/remix-dev/__tests__/readConfig-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe("readConfig", () => {
"future": {
"v3_fetcherPersist": false,
"v3_relativeSplatPath": false,
"v3_throwAbortReason": false,
},
"mdx": undefined,
"postcss": true,
Expand Down
2 changes: 2 additions & 0 deletions packages/remix-dev/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Dev = {
interface FutureConfig {
v3_fetcherPersist: boolean;
v3_relativeSplatPath: boolean;
v3_throwAbortReason: boolean;
}

type NodeBuiltinsPolyfillOptions = Pick<
Expand Down Expand Up @@ -596,6 +597,7 @@ export async function resolveConfig(
let future: FutureConfig = {
v3_fetcherPersist: appConfig.future?.v3_fetcherPersist === true,
v3_relativeSplatPath: appConfig.future?.v3_relativeSplatPath === true,
v3_throwAbortReason: appConfig.future?.v3_throwAbortReason === true,
};

if (appConfig.future) {
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@mdx-js/mdx": "^2.3.0",
"@npmcli/package-json": "^4.0.1",
"@remix-run/node": "2.5.1",
"@remix-run/router": "1.14.2",
"@remix-run/router": "0.0.0-experimental-c9f8a7b2",
"@remix-run/server-runtime": "2.5.1",
"@types/mdx": "^2.0.5",
"@vanilla-extract/integration": "^6.2.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/remix-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"typings": "dist/index.d.ts",
"module": "dist/esm/index.js",
"dependencies": {
"@remix-run/router": "1.14.2",
"@remix-run/router": "0.0.0-experimental-c9f8a7b2",
"@remix-run/server-runtime": "2.5.1",
"react-router": "6.21.3",
"react-router-dom": "6.21.3"
"react-router": "0.0.0-experimental-c9f8a7b2",
"react-router-dom": "0.0.0-experimental-c9f8a7b2"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.17.0",
Expand Down
Loading

0 comments on commit 4c627af

Please sign in to comment.