@remix-run/router 1.14.2 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remix-run/router",
3
- "version": "1.14.2",
3
+ "version": "1.15.0",
4
4
  "description": "Nested/Data-driven/Framework-agnostic Routing",
5
5
  "keywords": [
6
6
  "remix",
package/router.ts CHANGED
@@ -2834,6 +2834,7 @@ export const UNSAFE_DEFERRED_SYMBOL = Symbol("deferred");
2834
2834
  */
2835
2835
  export interface StaticHandlerFutureConfig {
2836
2836
  v7_relativeSplatPath: boolean;
2837
+ v7_throwAbortReason: boolean;
2837
2838
  }
2838
2839
 
2839
2840
  export interface CreateStaticHandlerOptions {
@@ -2872,6 +2873,7 @@ export function createStaticHandler(
2872
2873
  // Config driven behavior flags
2873
2874
  let future: StaticHandlerFutureConfig = {
2874
2875
  v7_relativeSplatPath: false,
2876
+ v7_throwAbortReason: false,
2875
2877
  ...(opts ? opts.future : null),
2876
2878
  };
2877
2879
 
@@ -3141,10 +3143,7 @@ export function createStaticHandler(
3141
3143
  );
3142
3144
 
3143
3145
  if (request.signal.aborted) {
3144
- let method = isRouteRequest ? "queryRoute" : "query";
3145
- throw new Error(
3146
- `${method}() call aborted: ${request.method} ${request.url}`
3147
- );
3146
+ throwStaticHandlerAbortedError(request, isRouteRequest, future);
3148
3147
  }
3149
3148
  }
3150
3149
 
@@ -3312,10 +3311,7 @@ export function createStaticHandler(
3312
3311
  ]);
3313
3312
 
3314
3313
  if (request.signal.aborted) {
3315
- let method = isRouteRequest ? "queryRoute" : "query";
3316
- throw new Error(
3317
- `${method}() call aborted: ${request.method} ${request.url}`
3318
- );
3314
+ throwStaticHandlerAbortedError(request, isRouteRequest, future);
3319
3315
  }
3320
3316
 
3321
3317
  // Process and commit output from loaders
@@ -3372,7 +3368,7 @@ export function getStaticContextFromError(
3372
3368
  ) {
3373
3369
  let newContext: StaticHandlerContext = {
3374
3370
  ...context,
3375
- statusCode: 500,
3371
+ statusCode: isRouteErrorResponse(error) ? error.status : 500,
3376
3372
  errors: {
3377
3373
  [context._deepestRenderedBoundaryId || routes[0].id]: error,
3378
3374
  },
@@ -3380,6 +3376,19 @@ export function getStaticContextFromError(
3380
3376
  return newContext;
3381
3377
  }
3382
3378
 
3379
+ function throwStaticHandlerAbortedError(
3380
+ request: Request,
3381
+ isRouteRequest: boolean,
3382
+ future: StaticHandlerFutureConfig
3383
+ ) {
3384
+ if (future.v7_throwAbortReason && request.signal.reason !== undefined) {
3385
+ throw request.signal.reason;
3386
+ }
3387
+
3388
+ let method = isRouteRequest ? "queryRoute" : "query";
3389
+ throw new Error(`${method}() call aborted: ${request.method} ${request.url}`);
3390
+ }
3391
+
3383
3392
  function isSubmissionNavigation(
3384
3393
  opts: BaseNavigateOrFetchOptions
3385
3394
  ): opts is SubmissionNavigateOptions {