Sentry 阻止我的 Next.js 应用程序构建

Eva*_*vaa 5 sentry next.js

我最近将哨兵添加到我的 nextjs 项目中。我的问题是这个错误阻止我的应用程序构建。我在运行时也遇到同样的错误,但令我困惑的是为什么它阻止我的应用程序构建。我可以以仅在运行时有效的方式配置它吗?

Failed to compile.

Sentry CLI Plugin: Command failed: D:\client-new\node_modules\@sentry\cli\sentry-cli.exe releases new SOME_KEY_CODE
error: API request failed
  caused by: [28] Timeout was reached (Failed to connect to sentry.io port 443 after 21064 ms: Timed out)

Add --log-level=[info|debug] or export SENTRY_LOG_LEVEL=[info|debug] to see more output.
Please attach the full debug log to all bug reports.

Sentry CLI Plugin: Command failed: D:\client-new\node_modules\@sentry\cli\sentry-cli.exe releases new SOME_KEY_CODE
error: API request failed
  caused by: [28] Timeout was reached (Failed to connect to sentry.io port 443 after 21053 ms: Timed out)

Add --log-level=[info|debug] or export SENTRY_LOG_LEVEL=[info|debug] to see more output.
Please attach the full debug log to all bug reports.


> Build failed because of webpack errors
Run Code Online (Sandbox Code Playgroud)

我正在使用 Next.js 12 和sentry/nextjs 7.28.1,并且在构建时在本地和服务器上都看到此错误。

jya*_*gca 1

sentry.server.config.js您可以通过在和上使用环境变量有条件地导入 Sentry 库,将 Sentry 配置为仅在运行时工作sentry.client.config.js

例子:

if (process.env.NODE_ENV === 'production' && process.env.SENTRY_DSN) {
  const Sentry = require('@sentry/node');
  Sentry.init({ dsn: process.env.SENTRY_DSN });
}
Run Code Online (Sandbox Code Playgroud)

希望能帮助到你。