我最近在我的 nextjs 项目中添加了 sentry。我的问题是这个错误阻止了我的应用程序的构建。我在运行时也有同样的错误,但令我困惑的是为什么它阻止我的应用程序构建。我可以以仅在运行时有效的方式配置它吗?
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
我正在使用 Next.js 12 和 sentry/nextjs 7.28.1 我在构建时在本地和服务器上都看到了这个错误。
您可以将 Sentry 配置为仅在运行时工作,方法是在
sentry.server.config.js
和 sentry.client.config.js
上使用环境变量有条件地导入 Sentry 库。
if (process.env.NODE_ENV === 'production' && process.env.SENTRY_DSN) {
const Sentry = require('@sentry/node');
Sentry.init({ dsn: process.env.SENTRY_DSN });
}
希望有帮助。