MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / warnOncePerSession

Function warnOncePerSession

server/src/middleware/auth.ts:49–63  ·  view source on GitHub ↗

Log at warn the first time a stale session is seen; demote repeats to debug.

(
  cacheKey: string,
  fields: Record<string, unknown>,
  message: string,
  suppressedMessage: string,
)

Source from the content-addressed store, hash-verified

47
48/** Log at warn the first time a stale session is seen; demote repeats to debug. */
49function warnOncePerSession(
50 cacheKey: string,
51 fields: Record<string, unknown>,
52 message: string,
53 suppressedMessage: string,
54): void {
55 const now = Date.now();
56 const firstSeen = authFailureLog.get(cacheKey);
57 if (!firstSeen || now - firstSeen > AUTH_FAILURE_LOG_SUPPRESS_MS) {
58 authFailureLog.set(cacheKey, now);
59 logger.warn(fields, message);
60 } else {
61 logger.debug(fields, suppressedMessage);
62 }
63}
64
65// Clean up expired cache entries periodically (every 5 minutes)
66setInterval(() => {

Callers 1

requireAuthFunction · 0.85

Calls 4

nowMethod · 0.80
warnMethod · 0.80
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected