From d9ee102335b13173ee8d4d375aa7d71de6db9aed Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 10 Dec 2024 11:43:05 +0100 Subject: [PATCH] feat(nextjs)!: Remove `experimental_captureRequestError` (#14607) Fixes https://github.com/getsentry/sentry-javascript/issues/14302 --- .../e2e-tests/test-applications/nextjs-t3/package.json | 6 +++--- .../test-applications/nextjs-t3/src/trpc/server.ts | 7 +++---- packages/nextjs/src/common/captureRequestError.ts | 8 -------- packages/nextjs/src/common/index.ts | 3 +-- packages/nextjs/src/index.types.ts | 3 +-- 5 files changed, 8 insertions(+), 19 deletions(-) diff --git a/dev-packages/e2e-tests/test-applications/nextjs-t3/package.json b/dev-packages/e2e-tests/test-applications/nextjs-t3/package.json index 2fd54b440e2e..4cdd6509ddbd 100644 --- a/dev-packages/e2e-tests/test-applications/nextjs-t3/package.json +++ b/dev-packages/e2e-tests/test-applications/nextjs-t3/package.json @@ -21,9 +21,9 @@ "@trpc/react-query": "^11.0.0-rc.446", "@trpc/server": "^11.0.0-rc.446", "geist": "^1.3.0", - "next": "^14.2.4", - "react": "^18.3.1", - "react-dom": "^18.3.1", + "next": "14.2.4", + "react": "18.3.1", + "react-dom": "18.3.1", "server-only": "^0.0.1", "superjson": "^2.2.1", "zod": "^3.23.3" diff --git a/dev-packages/e2e-tests/test-applications/nextjs-t3/src/trpc/server.ts b/dev-packages/e2e-tests/test-applications/nextjs-t3/src/trpc/server.ts index b6cb13a70781..7760873eb51d 100644 --- a/dev-packages/e2e-tests/test-applications/nextjs-t3/src/trpc/server.ts +++ b/dev-packages/e2e-tests/test-applications/nextjs-t3/src/trpc/server.ts @@ -2,7 +2,6 @@ import 'server-only'; import { createHydrationHelpers } from '@trpc/react-query/rsc'; import { headers } from 'next/headers'; -import { cache } from 'react'; import { type AppRouter, createCaller } from '~/server/api/root'; import { createTRPCContext } from '~/server/api/trpc'; @@ -12,16 +11,16 @@ import { createQueryClient } from './query-client'; * This wraps the `createTRPCContext` helper and provides the required context for the tRPC API when * handling a tRPC call from a React Server Component. */ -const createContext = cache(() => { +const createContext = () => { const heads = new Headers(headers()); heads.set('x-trpc-source', 'rsc'); return createTRPCContext({ headers: heads, }); -}); +}; -const getQueryClient = cache(createQueryClient); +const getQueryClient = createQueryClient; const caller = createCaller(createContext); export const { trpc: api, HydrateClient } = createHydrationHelpers(caller, getQueryClient); diff --git a/packages/nextjs/src/common/captureRequestError.ts b/packages/nextjs/src/common/captureRequestError.ts index 6de33ad11a8e..26fdaab4953b 100644 --- a/packages/nextjs/src/common/captureRequestError.ts +++ b/packages/nextjs/src/common/captureRequestError.ts @@ -41,11 +41,3 @@ export function captureRequestError(error: unknown, request: RequestInfo, errorC }); }); } - -/** - * Reports errors passed to the the Next.js `onRequestError` instrumentation hook. - * - * @deprecated Use `captureRequestError` instead. - */ -// TODO(v9): Remove this export -export const experimental_captureRequestError = captureRequestError; diff --git a/packages/nextjs/src/common/index.ts b/packages/nextjs/src/common/index.ts index 7740c35c016c..b9a652522349 100644 --- a/packages/nextjs/src/common/index.ts +++ b/packages/nextjs/src/common/index.ts @@ -11,5 +11,4 @@ export { wrapMiddlewareWithSentry } from './wrapMiddlewareWithSentry'; export { wrapPageComponentWithSentry } from './pages-router-instrumentation/wrapPageComponentWithSentry'; export { wrapGenerationFunctionWithSentry } from './wrapGenerationFunctionWithSentry'; export { withServerActionInstrumentation } from './withServerActionInstrumentation'; -// eslint-disable-next-line deprecation/deprecation -export { experimental_captureRequestError, captureRequestError } from './captureRequestError'; +export { captureRequestError } from './captureRequestError'; diff --git a/packages/nextjs/src/index.types.ts b/packages/nextjs/src/index.types.ts index 1b6a0e09ed85..1b965828116f 100644 --- a/packages/nextjs/src/index.types.ts +++ b/packages/nextjs/src/index.types.ts @@ -142,5 +142,4 @@ export declare function wrapApiHandlerWithSentryVercelCrons(WrappingTarget: C): C; -// eslint-disable-next-line deprecation/deprecation -export { experimental_captureRequestError, captureRequestError } from './common/captureRequestError'; +export { captureRequestError } from './common/captureRequestError';