From b97408437d538f5948406e5e61fc58e87ccf4e0a Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Thu, 10 Mar 2022 23:33:18 -0800 Subject: [PATCH] add env var to suppress warning --- packages/nextjs/src/utils/withSentry.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/nextjs/src/utils/withSentry.ts b/packages/nextjs/src/utils/withSentry.ts index bc1f1a69770c..4b8a9e9bb36c 100644 --- a/packages/nextjs/src/utils/withSentry.ts +++ b/packages/nextjs/src/utils/withSentry.ts @@ -86,10 +86,12 @@ export const withSentry = (origHandler: NextApiHandler): WrappedNextApiHandler = try { const handlerResult = await origHandler(req, res); - if (process.env.NODE_ENV === 'development') { + if (process.env.NODE_ENV === 'development' && !process.env.SENTRY_IGNORE_API_RESOLUTION_ERROR) { // eslint-disable-next-line no-console console.warn( - '[sentry] If Next.js logs a warning "API resolved without sending a response", it\'s a false positive, which we\'re working to rectify.', + `[sentry] If Next.js logs a warning "API resolved without sending a response", it's a false positive, which we're working to rectify. + In the meantime, to suppress this warning, set \`SENTRY_IGNORE_API_RESOLUTION_ERROR\` to 1 in your env. + To suppress the nextjs warning, use the \`externalResolver\` API route option (see https://nextjs.org/docs/api-routes/api-middlewares#custom-config for details).`, ); }