mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 05:59:00 +08:00
feat: git hash on error (#9373)
This commit is contained in:
@@ -6,6 +6,7 @@ const path = require('path');
|
|||||||
const { RequestInProgressError } = require('@/errors');
|
const { RequestInProgressError } = require('@/errors');
|
||||||
|
|
||||||
let Sentry;
|
let Sentry;
|
||||||
|
let gitHash;
|
||||||
|
|
||||||
if (config.sentry.dsn) {
|
if (config.sentry.dsn) {
|
||||||
Sentry = Sentry || require('@sentry/node');
|
Sentry = Sentry || require('@sentry/node');
|
||||||
@@ -19,6 +20,12 @@ if (config.sentry.dsn) {
|
|||||||
logger.info('Sentry inited.');
|
logger.info('Sentry inited.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
gitHash = require('git-rev-sync').short();
|
||||||
|
} catch (e) {
|
||||||
|
gitHash = (process.env.HEROKU_SLUG_COMMIT && process.env.HEROKU_SLUG_COMMIT.slice(0, 7)) || (process.env.VERCEL_GITHUB_COMMIT_SHA && process.env.VERCEL_GITHUB_COMMIT_SHA.slice(0, 7)) || 'unknown';
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = async (ctx, next) => {
|
module.exports = async (ctx, next) => {
|
||||||
try {
|
try {
|
||||||
const time = +new Date();
|
const time = +new Date();
|
||||||
@@ -68,6 +75,7 @@ module.exports = async (ctx, next) => {
|
|||||||
message,
|
message,
|
||||||
errorPath: ctx.path,
|
errorPath: ctx.path,
|
||||||
nodeVersion: process.version,
|
nodeVersion: process.version,
|
||||||
|
gitHash,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
Helpful Information to provide when opening issue:
|
Helpful Information to provide when opening issue:
|
||||||
Path: {{@ errorPath }}
|
Path: {{@ errorPath }}
|
||||||
Node version: {{@ nodeVersion}}
|
Node version: {{@ nodeVersion}}
|
||||||
|
Git Hash: {{@ gitHash}}
|
||||||
</pre>
|
</pre>
|
||||||
<pre class="message">
|
<pre class="message">
|
||||||
如果您认为 RSSHub 导致了该错误,请在Github按照模版,复制本页面信息进行<a href="https://github.com/DIYgod/RSSHub/issues/new?assignees=&labels=RSS+bug&template=bug_report_zh.yml" target="_blank">汇报</a>
|
如果您认为 RSSHub 导致了该错误,请在Github按照模版,复制本页面信息进行<a href="https://github.com/DIYgod/RSSHub/issues/new?assignees=&labels=RSS+bug&template=bug_report_zh.yml" target="_blank">汇报</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user