Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 1 addition & 23 deletions packages/tanstackstart-react/src/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1 @@
/**
* A middleware handler that can be passed to TanStack Start's `createMiddleware().server(...)` method as [global middleware](https://tanstack.com/start/latest/docs/framework/react/middleware#global-middleware) for instrumenting server functions.
*/
export function sentryGlobalServerMiddlewareHandler() {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return function <T>(server: { next: (...args: any[]) => T }): T {
return server.next();
};
}

/**
* Wraps a TanStack Start stream handler with Sentry instrumentation that can be passed to `createStartHandler(...)`.
*/
export function wrapStreamHandlerWithSentry<H>(handler: H): H {
return handler;
}

/**
* Wraps the create root route function with Sentry for server-client tracing with SSR.
*/
export function wrapCreateRootRouteWithSentry<F>(createRootRoute: F): F {
return createRootRoute;
}
export {};
17 changes: 1 addition & 16 deletions packages/tanstackstart-react/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1 @@
/**
* Wraps a TanStack Start config.
*/
export function wrapVinxiConfigWithSentry<C>(
config: C,
// TODO: Expand this type in the future. Right now it is just so that TS doesn't complain for our users when they copy paste from the docs.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
sentryBuildOptions: {
org?: string;
project?: string;
silent?: boolean;
authToken?: string;
} = {},
): C {
return config;
}
export {};
2 changes: 2 additions & 0 deletions packages/tanstackstart-react/src/index.server.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable import/export */

export * from './config';
export * from './server';
export * from './common';
14 changes: 0 additions & 14 deletions packages/tanstackstart-react/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ export const ErrorBoundary = (props: React.PropsWithChildren<unknown>): React.Re
return props.children;
};

/**
* A passthrough redux enhancer for the server that doesn't depend on anything from the `@sentry/react` package.
*/
export function createReduxEnhancer() {
return (createStore: unknown) => createStore;
}

/**
* A passthrough error boundary wrapper for the server that doesn't depend on any react. Error boundaries don't catch
* SSR errors so they should simply be a passthrough.
Comment on lines 16 to 21
Copy link

Choose a reason for hiding this comment

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

Bug: createReduxEnhancer() and showReportDialog() are declared in types but are undefined at runtime on the server, causing TypeError.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The PR removes createReduxEnhancer() and showReportDialog() from packages/tanstackstart-react/src/server/index.ts. However, their type declarations persist in packages/tanstackstart-react/src/index.types.ts. This allows TypeScript to permit calls to Sentry.createReduxEnhancer() and Sentry.showReportDialog() on the server. At runtime, these functions are undefined because they are no longer exported, leading to a TypeError: ... is not a function if invoked.

💡 Suggested Fix

Remove or update the type declarations for createReduxEnhancer() and showReportDialog() in packages/tanstackstart-react/src/index.types.ts to align with their removal from server/index.ts.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: packages/tanstackstart-react/src/server/index.ts#L16-L21

Potential issue: The PR removes `createReduxEnhancer()` and `showReportDialog()` from
`packages/tanstackstart-react/src/server/index.ts`. However, their type declarations
persist in `packages/tanstackstart-react/src/index.types.ts`. This allows TypeScript to
permit calls to `Sentry.createReduxEnhancer()` and `Sentry.showReportDialog()` on the
server. At runtime, these functions are `undefined` because they are no longer exported,
leading to a `TypeError: ... is not a function` if invoked.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 3982457

Expand All @@ -33,10 +26,3 @@ export function withErrorBoundary<P extends Record<string, any>>(
): React.FC<P> {
return WrappedComponent as React.FC<P>;
}

/**
* Just a passthrough since we're on the server and showing the report dialog on the server doesn't make any sense.
*/
export function showReportDialog(): void {
return;
}
Loading