@kb-labs/gateway-app 2.107.0 → 2.110.0

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 CHANGED
@@ -14,6 +14,7 @@ import fastifyCors from '@fastify/cors';
14
14
  import fastifyHttpProxy from '@fastify/http-proxy';
15
15
  import { PERMISSIONS, CANONICAL_OBSERVABILITY_METRICS, OBSERVABILITY_CONTRACT_VERSION, OBSERVABILITY_SCHEMA } from '@kb-labs/core-contracts';
16
16
  import { randomBytes, randomUUID, createHmac, timingSafeEqual } from 'crypto';
17
+ import { classifyFailure } from '@kb-labs/core-retry';
17
18
  import { WebSocketServer, WebSocket } from 'ws';
18
19
  import { hostname } from 'os';
19
20
  import { monitorEventLoopDelay, performance } from 'perf_hooks';
@@ -1140,8 +1141,8 @@ async function executeWithRetry(ctx, dispatch) {
1140
1141
  if (attempt >= maxAttempts) {
1141
1142
  break;
1142
1143
  }
1143
- const classified = classifyError(err);
1144
- if (cfg.onlyRetryable && !classified.retryable) {
1144
+ const classified = classifyFailure(err, { source: "transport", phase: "dispatch" });
1145
+ if (cfg.onlyRetryable && !classified.transient) {
1145
1146
  break;
1146
1147
  }
1147
1148
  const delay = Math.min(
@@ -1194,19 +1195,6 @@ function interruptibleDelay(ms, signal) {
1194
1195
  signal.addEventListener("abort", onAbort, { once: true });
1195
1196
  });
1196
1197
  }
1197
- function classifyError(err) {
1198
- if (!(err instanceof Error)) {
1199
- return { code: "UNKNOWN", message: String(err), retryable: false };
1200
- }
1201
- const msg = err.message;
1202
- if (msg.includes("ECONNREFUSED") || msg.includes("ECONNRESET") || msg.includes("ETIMEDOUT") || msg.includes("timed out") || msg.includes("503") || msg.includes("Service Unavailable")) {
1203
- return { code: "TRANSPORT_ERROR", message: msg, retryable: true };
1204
- }
1205
- if (msg.includes("Host not connected")) {
1206
- return { code: "HOST_UNAVAILABLE", message: msg, retryable: true };
1207
- }
1208
- return { code: "HANDLER_ERROR", message: msg, retryable: false };
1209
- }
1210
1198
 
1211
1199
  // src/execute/routes.ts
1212
1200
  function registerExecuteRoutes(app, logger) {