@semiont/backend 0.4.19 → 0.4.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +19 -5
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import winston from 'winston';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import jwt from 'jsonwebtoken';
|
|
5
|
-
import { email, userId, googleCredential, annotationId, resourceId, userToDid, EventBus, accessToken, jobId, entityType, assembleAnnotation, userToAgent, PERSISTED_EVENT_TYPES, STREAM_COMMAND_RESULT_TYPES } from '@semiont/core';
|
|
5
|
+
import { email, userId, googleCredential, annotationId, resourceId, userToDid, EventBus, accessToken, errField, jobId, entityType, assembleAnnotation, userToAgent, PERSISTED_EVENT_TYPES, STREAM_COMMAND_RESULT_TYPES } from '@semiont/core';
|
|
6
6
|
import { cors } from 'hono/cors';
|
|
7
7
|
import { serve } from '@hono/node-server';
|
|
8
8
|
import { Hono } from 'hono';
|
|
@@ -18769,7 +18769,7 @@ function registerGetEventStream(router) {
|
|
|
18769
18769
|
logger2.error("Error writing event to SSE stream", {
|
|
18770
18770
|
streamId,
|
|
18771
18771
|
eventType: storedEvent.type,
|
|
18772
|
-
error
|
|
18772
|
+
error: errField(error)
|
|
18773
18773
|
});
|
|
18774
18774
|
cleanup();
|
|
18775
18775
|
}
|
|
@@ -18829,7 +18829,7 @@ function registerGetEventStream(router) {
|
|
|
18829
18829
|
logger2.error("Error writing command-result event to SSE stream", {
|
|
18830
18830
|
streamId,
|
|
18831
18831
|
eventType,
|
|
18832
|
-
error
|
|
18832
|
+
error: errField(error)
|
|
18833
18833
|
});
|
|
18834
18834
|
cleanup();
|
|
18835
18835
|
}
|
|
@@ -19356,7 +19356,7 @@ globalEventsRouter.get("/api/events/stream", async (c) => {
|
|
|
19356
19356
|
logger2.error("Error writing event to global SSE stream", {
|
|
19357
19357
|
streamId,
|
|
19358
19358
|
eventType: storedEvent.type,
|
|
19359
|
-
error
|
|
19359
|
+
error: errField(error)
|
|
19360
19360
|
});
|
|
19361
19361
|
cleanup();
|
|
19362
19362
|
}
|
|
@@ -19491,7 +19491,7 @@ function registerAttentionStream(router) {
|
|
|
19491
19491
|
id: String(Date.now())
|
|
19492
19492
|
});
|
|
19493
19493
|
} catch (error) {
|
|
19494
|
-
logger2.error("Error writing beckon signal to attention stream", { error });
|
|
19494
|
+
logger2.error("Error writing beckon signal to attention stream", { error: errField(error) });
|
|
19495
19495
|
cleanup();
|
|
19496
19496
|
}
|
|
19497
19497
|
});
|
|
@@ -19686,6 +19686,20 @@ if (!config.services.backend.corsOrigin) {
|
|
|
19686
19686
|
var backendService = config.services.backend;
|
|
19687
19687
|
initializeLogger(config.logLevel);
|
|
19688
19688
|
var logger = getLogger();
|
|
19689
|
+
{
|
|
19690
|
+
const { monitorEventLoopDelay } = await import('perf_hooks');
|
|
19691
|
+
const h = monitorEventLoopDelay({ resolution: 20 });
|
|
19692
|
+
h.enable();
|
|
19693
|
+
const monitorLogger = logger.child({ component: "event-loop-monitor" });
|
|
19694
|
+
setInterval(() => {
|
|
19695
|
+
const maxMs = Number((h.max / 1e6).toFixed(1));
|
|
19696
|
+
const p99Ms = Number((h.percentile(99) / 1e6).toFixed(1));
|
|
19697
|
+
const meanMs = Number((h.mean / 1e6).toFixed(1));
|
|
19698
|
+
const level = p99Ms > 100 ? "warn" : "info";
|
|
19699
|
+
monitorLogger.log(level, "event-loop delay", { meanMs, p99Ms, maxMs });
|
|
19700
|
+
h.reset();
|
|
19701
|
+
}, 3e4).unref();
|
|
19702
|
+
}
|
|
19689
19703
|
if (databaseUrlConstructed) {
|
|
19690
19704
|
logger.info("DATABASE_URL constructed from environment components", {
|
|
19691
19705
|
host: process.env.DB_HOST,
|