Skip to content

Commit a5a3b0e

Browse files
committed
Cleanup
1 parent 26eee92 commit a5a3b0e

File tree

4 files changed

+18
-23
lines changed

4 files changed

+18
-23
lines changed

packages/remix/src/server/errors.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type {
44
HandleDocumentRequestFunction,
55
LoaderFunctionArgs,
66
} from '@remix-run/node';
7-
import type { ActionFunction, LoaderFunction } from '@remix-run/server-runtime';
87
import type { RequestEventData, Span } from '@sentry/core';
98
import {
109
addExceptionMechanism,
@@ -17,11 +16,10 @@ import {
1716
} from '@sentry/core';
1817
import { DEBUG_BUILD } from '../utils/debug-build';
1918
import type { RemixOptions } from '../utils/remixOptions';
19+
import type { DataFunction } from '../utils/types';
2020
import { storeFormDataKeys } from '../utils/utils';
2121
import { extractData, isResponse, isRouteErrorResponse } from '../utils/vendor/response';
2222

23-
type DataFunction = LoaderFunction | ActionFunction;
24-
2523
/**
2624
* Captures an exception happened in the Remix server.
2725
*

packages/remix/src/server/instrumentServer.ts

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
/* eslint-disable max-lines */
2+
import type { UNSAFE_DeferredData as DeferredData } from '@remix-run/router';
23
import type {
3-
ActionFunction,
4-
ActionFunctionArgs,
54
AppLoadContext,
65
CreateRequestHandlerFunction,
76
EntryContext,
87
HandleDocumentRequestFunction,
9-
LoaderFunction,
10-
LoaderFunctionArgs,
118
RequestHandler,
129
ServerBuild,
1310
} from '@remix-run/server-runtime';
@@ -33,14 +30,11 @@ import {
3330
withIsolationScope,
3431
} from '@sentry/core';
3532
import { DEBUG_BUILD } from '../utils/debug-build';
36-
import type { DeferredData, Route, ServerRouteManifest } from '../utils/types';
33+
import type { AppData, DataFunction, DataFunctionArgs, Route, ServerRouteManifest } from '../utils/types';
3734
import { createRoutes, getTransactionName } from '../utils/utils';
3835
import { extractData, isDeferredData, isResponse, isRouteErrorResponse, json } from '../utils/vendor/response';
3936
import { captureRemixServerException, errorHandleDataFunction, errorHandleDocumentRequestFunction } from './errors';
4037

41-
type DataFunction = LoaderFunction | ActionFunction;
42-
type DataFunctionArgs = LoaderFunctionArgs | ActionFunctionArgs;
43-
4438
const redirectStatusCodes = new Set([301, 302, 303, 307, 308]);
4539
function isRedirectResponse(response: Response): boolean {
4640
return redirectStatusCodes.has(response.status);
@@ -165,7 +159,7 @@ function makeWrappedDataFunction(
165159
name: 'action' | 'loader',
166160
instrumentTracing?: boolean,
167161
): DataFunction {
168-
return async function (this: unknown, args: DataFunctionArgs): Promise<Response> {
162+
return async function (this: unknown, args: DataFunctionArgs): Promise<Response | AppData> {
169163
if (instrumentTracing) {
170164
return startSpan(
171165
{
@@ -200,7 +194,7 @@ const makeWrappedLoader =
200194

201195
function makeWrappedRootLoader() {
202196
return function (origLoader: DataFunction): DataFunction {
203-
return async function (this: unknown, args: DataFunctionArgs): Promise<Response | DeferredData> {
197+
return async function (this: unknown, args: DataFunctionArgs): Promise<Response | AppData> {
204198
const res = await origLoader.call(this, args);
205199
const traceAndBaggage = getTraceAndBaggage();
206200

packages/remix/src/utils/types.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1+
import type { ActionFunction, ActionFunctionArgs, LoaderFunction, LoaderFunctionArgs } from '@remix-run/server-runtime';
2+
13
export type SentryMetaArgs<MetaFN extends (...args: any) => any> = Parameters<MetaFN>[0] & {
24
data: {
35
sentryTrace: string;
46
sentryBaggage: string;
57
};
68
};
79

8-
export type DeferredData = {
9-
data: Record<string, unknown>;
10-
deferredKeys: string[];
11-
subscribe(fn: (aborted: boolean, settledKey?: string) => void): () => boolean;
12-
cancel(): void;
13-
resolveData(signal: AbortSignal): Promise<boolean>;
14-
};
15-
1610
export interface RouteManifest<Route> {
1711
[routeId: string]: Route;
1812
}
@@ -30,3 +24,7 @@ export interface Route {
3024
parentId?: string;
3125
path?: string;
3226
}
27+
28+
export type DataFunction = LoaderFunction | ActionFunction;
29+
export type DataFunctionArgs = LoaderFunctionArgs | ActionFunctionArgs;
30+
export type AppData = unknown;

packages/remix/src/utils/vendor/response.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@
66
//
77
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
88

9-
import type { AgnosticRouteMatch, AgnosticRouteObject, ErrorResponse } from '@remix-run/router';
9+
import type {
10+
AgnosticRouteMatch,
11+
AgnosticRouteObject,
12+
ErrorResponse,
13+
UNSAFE_DeferredData as DeferredData,
14+
} from '@remix-run/router';
1015
import { matchRoutes } from '@remix-run/router';
11-
import type { DeferredData, Route } from '../types';
16+
import type { Route } from '../types';
1217

1318
/**
1419
* Based on Remix Implementation

0 commit comments

Comments
 (0)