-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(nextjs): Add automatic monitors for Vercel Cron Jobs #8088
Changes from 7 commits
23345d5
64a3003
bcd2bc2
5ff80e4
aaa8206
4b8f309
1e1711d
9d18786
49f334f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import * as chalk from 'chalk'; | |
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
|
||
import type { VercelCronsConfig } from '../common/types'; | ||
// Note: If you need to import a type from Webpack, do it in `types.ts` and export it from there. Otherwise, our | ||
// circular dependency check thinks this file is importing from itself. See https://github.com/pahen/madge/issues/306. | ||
import type { | ||
|
@@ -163,6 +164,29 @@ export function constructWebpackConfigFunction( | |
], | ||
}); | ||
|
||
let vercelCronsConfig: VercelCronsConfig = undefined; | ||
try { | ||
if (process.env.VERCEL && userSentryOptions.automaticVercelMonitors !== false) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
vercelCronsConfig = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'vercel.json'), 'utf8')).crons; | ||
logger.info( | ||
`${chalk.cyan( | ||
'info', | ||
)} - Creating Sentry cron monitors for your Vercel Cron Jobs. You can disable this feature by setting the ${chalk.bold.cyan( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. m: Should we only log this out if the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
'automaticVercelMonitors', | ||
)} option to false in you Next.js config.`, | ||
); | ||
} | ||
} catch (e) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
if (e.code === 'ENOENT') { | ||
// noop if file does not exist | ||
} else { | ||
// log but noop | ||
logger.error(`${chalk.red('error')} - Sentry failed to read vercel.json`, e); | ||
} | ||
} | ||
|
||
// Wrap api routes | ||
newConfig.module.rules.unshift({ | ||
test: resourcePath => { | ||
|
@@ -177,6 +201,7 @@ export function constructWebpackConfigFunction( | |
loader: path.resolve(__dirname, 'loaders', 'wrappingLoader.js'), | ||
options: { | ||
...staticWrappingLoaderOptions, | ||
vercelCronsConfig, | ||
wrappingTargetKind: 'api-route', | ||
}, | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a discussion with the crons team. The missed checkins were a bug in the product when the margin is set to 0.