getServerSideProps issue `Cannot use 'in' operator to search for 'props' in undefined`
MatteoGauthier opened this issue · comments
Verify Next.js canary release
- I verified that the issue exists in the latest Next.js canary release
Describe the bug
I have an issue with Sentry + Superjson + next-superjson-plugin
"next-superjson-plugin": "^0.6.3",
"@sentry/nextjs": "7.106.1",
⨯ TypeError: Cannot use 'in' operator to search for 'props' in undefined
at withSuperJSON (file:///Users/xxxxxxxx/node_modules/.pnpm/next-superjson-plugin@0.6.3_next@14.2.0-canary.19_superjson@2.2.1/node_modules/next-superjson-plugin/dist/tools.js:8:23)
at async /Users/xxxxxxxx/node_modules/.pnpm/@sentry+nextjs@7.106.1_next@14.2.0-canary.19_react@18.2.0_webpack@5.90.3/node_modules/@sentry/nextjs/cjs/common/utils/wrapperUtils.js:38:14
at async /Users/xxxxxxxx/node_modules/.pnpm/@sentry+nextjs@7.106.1_next@14.2.0-canary.19_react@18.2.0_webpack@5.90.3/node_modules/@sentry/nextjs/cjs/common/utils/wrapperUtils.js:113:24
at async Object.apply (/Users/xxxxxxxx/node_modules/.pnpm/@sentry+nextjs@7.106.1_next@14.2.0-canary.19_react@18.2.0_webpack@5.90.3/node_modules/@sentry/nextjs/cjs/common/wrapGetServerSidePropsWithSentry.js:45:33)
at async e3 (/Users/xxxxxxxx/node_modules/.pnpm/next@14.2.0-canary.19_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/pages.runtime.dev.js:25:124)
at async doRender (/Users/xxxxxxxx/node_modules/.pnpm/next@14.2.0-canary.19_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/base-server.js:1411:30)
at async cacheEntry.responseCache.get.routeKind (/Users/xxxxxxxx/node_modules/.pnpm/next@14.2.0-canary.19_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/base-server.js:1585:28)
at async DevServer.renderToResponseWithComponentsImpl (/Users/xxxxxxxx/node_modules/.pnpm/next@14.2.0-canary.19_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/base-server.js:1493:28)
at async DevServer.renderPageComponent (/Users/xxxxxxxx/node_modules/.pnpm/next@14.2.0-canary.19_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/base-server.js:1908:24)
at async DevServer.renderToResponseImpl (/Users/xxxxxxxx/node_modules/.pnpm/next@14.2.0-canary.19_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/base-server.js:1946:32)
at async DevServer.pipeImpl (/Users/xxxxxxxx/node_modules/.pnpm/next@14.2.0-canary.19_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/base-server.js:910:25)
at async NextNodeServer.handleCatchallRenderRequest (/Users/xxxxxxxx/node_modules/.pnpm/next@14.2.0-canary.19_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/next-server.js:272:17)
at async DevServer.handleRequestImpl (/Users/xxxxxxxx/node_modules/.pnpm/next@14.2.0-canary.19_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/base-server.js:806:17)
at async /Users/xxxxxxxx/node_modules/.pnpm/next@14.2.0-canary.19_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/dev/next-dev-server.js:339:20
at async Span.traceAsyncFn (/Users/xxxxxxxx/node_modules/.pnpm/next@14.2.0-canary.19_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/trace/trace.js:151:20) {
page: '/admin/lessons/clsosaa960002o192nre5wkza'
}
Expected behavior
No crash
Reproduction link
No response
Version
0.6.3
Config
import { withSentryConfig } from "@sentry/nextjs"
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
* for Docker builds.
*/
await import("./src/env.mjs")
/** @type {import("next").NextConfig} */
const config = {
reactStrictMode: true,
async headers() {
return [
{
// @todo Refine this for better security
source: "/api/:path*",
headers: [
{ key: "Access-Control-Allow-Credentials", value: "true" },
{ key: "Access-Control-Allow-Origin", value: `*` },
{ key: "Access-Control-Allow-Methods", value: "GET,OPTIONS,PATCH,DELETE,POST,PUT" },
{
key: "Access-Control-Allow-Headers",
value:
"X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version",
},
],
},
]
},
i18n: {
locales: ["en"],
defaultLocale: "en",
},
experimental: {
swcPlugins: [
[
"next-superjson-plugin",
{
excluded: [],
},
],
],
},
}
export default withSentryConfig(
config,
{
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options
// Suppresses source map uploading logs during build
silent: true,
org: "xxxxx",
project: "xxxxx",
},
{
// For all available options, see:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,
// Transpiles SDK to be compatible with IE11 (increases bundle size)
transpileClientSDK: true,
// Hides source maps from generated client bundles
hideSourceMaps: true,
// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
// Enables automatic instrumentation of Vercel Cron Monitors.
// See the following for more information:
// https://docs.sentry.io/product/crons/
// https://vercel.com/docs/cron-jobs
automaticVercelMonitors: true,
}
)
Additional context
The problematic gSSP method :
export const getServerSideProps = async (context: GetServerSidePropsContext<{ id: string }>) => {
const data = await db.course.findUnique({ where: { id: context.params?.id } })
if (data) return data
return {
notFound: true,
}
}