feat: timestamp in ap errors page

This commit is contained in:
Julian Lam
2026-04-10 14:20:03 -04:00
parent 3915790793
commit 55ce9c07e4
2 changed files with 9 additions and 5 deletions

View File

@@ -87,11 +87,12 @@ federationController.analytics = async function (req, res) {
};
federationController.errors = async function (req, res) {
const ids = await db.getSortedSetRevRangeByScore('ap.errors', 0, -1, Date.now(), '-inf');
const errorObj = await db.getObjects(ids.map(id => `ap.errors:${id}`));
const errors = ids.map((id, idx) => {
let errors = await db.getSortedSetRevRangeByScoreWithScores('ap.errors', 0, -1, Date.now(), '-inf');
const errorObj = await db.getObjects(errors.map(({ value: id }) => `ap.errors:${id}`));
errors = errors.map(({ value: id, score: timestamp }, idx) => {
let { body, stack } = errorObj[idx];
let hostname = 'Invalid hostname';
const timestampISO = new Date(timestamp).toISOString();
try {
body = JSON.stringify(JSON.parse(body), null, 4);
({ hostname } = new URL(id));
@@ -99,7 +100,7 @@ federationController.errors = async function (req, res) {
// noop
}
return { id, body, stack, hostname };
return { id, body, stack, hostname, timestamp, timestampISO };
});
res.render('admin/federation/errors', {

View File

@@ -10,7 +10,10 @@
<div class="col-12 col-md-4" id="errors">
{{{ each errors }}}
<details class="mb-3" data-index="{@index}">
<summary>{./id}</summary>
<summary>
<span title="{./timestampISO}" class="timeago text-secondary text-sm"></span><br/ >
<code>{./id}</code>
</summary>
{{{ if ./stack }}}
<pre class="m-2 border p-2"><code>{./stack}</code></pre>