v2.1.11 - Fix api-worker DB lifecycle and NIP test reliability: add dedicated worker DB connection, guard PG expiration cast in REQ path, correct NIP-45 baseline-aware expectation, and harden run_all_tests skip handling

This commit is contained in:
Laan Tungir
2026-04-03 07:32:14 -04:00
parent 9a9365dcfa
commit 232f93c16f
25 changed files with 2693 additions and 114 deletions
+23
View File
@@ -496,6 +496,29 @@ WEB OF TRUST
RELAY EVENTS MANAGEMENT
</div>
<!-- Live Relay Event Feed -->
<div class="input-group">
<h3>Live Relay Event Feed (Normal Nostr Subscription)</h3>
<div class="config-table-container">
<table class="config-table" id="live-relay-events-table">
<thead>
<tr>
<th>Time</th>
<th>Kind</th>
<th>Pubkey</th>
<th>ID</th>
<th>Content Preview</th>
</tr>
</thead>
<tbody id="live-relay-events-table-body">
<tr>
<td colspan="5" style="text-align: center;">Waiting for live events...</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- Kind 0: User Metadata -->
<div class="input-group">
<h3>Kind 0: User Metadata</h3>
+51
View File
@@ -50,6 +50,7 @@ let pendingSqlQueries = new Map();
// Real-time event rate chart
let eventRateChart = null;
let previousTotalEvents = 0; // Track previous total for rate calculation
const liveRelayEventIds = new Set(); // Deduplicate live feed rows
// Temporary diagnostics toggle: enable deep SimplePool diagnostics in nostr.bundle.js
window.__SIMPLE_POOL_DEBUG__ = true;
@@ -1329,6 +1330,10 @@ async function subscribeToConfiguration() {
kinds: [0, 10050, 10002], // Relay events: metadata, DM relays, relay list
authors: [getRelayPubkey()], // Only listen to relay's own events
limit: 10
}, {
// Live feed uses a normal Nostr subscription, not monitoring events
since: Math.floor(Date.now() / 1000),
limit: 200
}], {
async onevent(event) {
// Simplified logging - one line per event
@@ -1434,6 +1439,11 @@ async function subscribeToConfiguration() {
if ([0, 10050, 10002].includes(event.kind)) {
handleRelayEventReceived(event);
}
// Real-time live feed via normal subscription (exclude monitoring/admin traffic)
if (event.kind !== 24567 && event.kind !== 23457 && event.kind !== 23456) {
addEventToLiveFeed(event);
}
},
oneose() {
console.log('EOSE received - End of stored events');
@@ -6026,6 +6036,47 @@ function initializeToggleButtonsFromConfig(configData) {
// ================================
function addEventToLiveFeed(event) {
if (!event || !event.id) return;
if (liveRelayEventIds.has(event.id)) return;
liveRelayEventIds.add(event.id);
const tableBody = document.getElementById('live-relay-events-table-body');
if (!tableBody) return;
const preview = typeof event.content === 'string'
? event.content.slice(0, 120)
: JSON.stringify(event.content || '').slice(0, 120);
const row = document.createElement('tr');
row.innerHTML = `
<td>${new Date((event.created_at || Math.floor(Date.now() / 1000)) * 1000).toLocaleTimeString()}</td>
<td>${event.kind ?? '-'}</td>
<td title="${escapeHtml(event.pubkey || '')}">${escapeHtml((event.pubkey || '').slice(0, 16))}...</td>
<td title="${escapeHtml(event.id || '')}">${escapeHtml((event.id || '').slice(0, 16))}...</td>
<td>${escapeHtml(preview)}</td>
`;
const waitingRow = tableBody.querySelector('tr td[colspan="5"]');
if (waitingRow) {
tableBody.innerHTML = '';
}
tableBody.insertBefore(row, tableBody.firstChild);
while (tableBody.children.length > 100) {
const last = tableBody.lastChild;
if (last && last.querySelector('td:nth-child(4)')) {
const idText = last.querySelector('td:nth-child(4)').textContent || '';
if (idText.endsWith('...')) {
// keep set bounded even with truncated display
// actual id remains in Set until page reload (acceptable for UI scope)
}
}
tableBody.removeChild(last);
}
}
// Handle received relay events
function handleRelayEventReceived(event) {
console.log('Handling relay event:', event.kind, event);