@friggframework/core 2.0.0-next.76 → 2.0.0-next.78

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.
@@ -12,14 +12,14 @@ class FetchError extends BaseError {
12
12
  constructor(options = {}) {
13
13
  const { resource, init, response, responseBody } = options;
14
14
  const method = init?.method ?? 'GET';
15
- const initText = init
15
+ let initText = init
16
16
  ? init.body instanceof URLSearchParams
17
17
  ? (() => {
18
- init.body = init.body.toString();
19
- return JSON.stringify({ init }, null, 2);
20
- })()
18
+ init.body = init.body.toString();
19
+ return JSON.stringify({ init }, null, 2);
20
+ })()
21
21
  : JSON.stringify({ init }, null, 2)
22
- : '';
22
+ : '';
23
23
 
24
24
  let responseBodyText = '<response body is unavailable>';
25
25
  if (typeof responseBody === 'string') {
@@ -35,10 +35,17 @@ class FetchError extends BaseError {
35
35
  }
36
36
  }
37
37
 
38
- const responseHeaderText = response
38
+ let responseHeaderText = response
39
39
  ? JSON.stringify({ headers: responseHeaders }, null, 2)
40
40
  : '';
41
41
 
42
+ // sanitize error reporting
43
+ if (process.env.STAGE !== 'dev') {
44
+ initText = false;
45
+ responseHeaderText = false;
46
+ responseBodyText = false;
47
+ }
48
+
42
49
  const messageParts = [
43
50
  stripIndent`
44
51
  -----------------------------------------------------
@@ -154,6 +154,12 @@ const createQueueWorker = (integrationClass) => {
154
154
  params.data.processId,
155
155
  integrationClass
156
156
  );
157
+ if (integrationInstance?.status === 'DISABLED') {
158
+ console.warn(
159
+ `[${integrationClass.Definition.name}] Integration for process ${params.data.processId} is DISABLED. Discarding ${params.event} message.`
160
+ );
161
+ return;
162
+ }
157
163
  } else if (params.data?.integrationId) {
158
164
  integrationInstance = await loadIntegrationForWebhook(
159
165
  params.data.integrationId
@@ -164,6 +170,12 @@ const createQueueWorker = (integrationClass) => {
164
170
  );
165
171
  return;
166
172
  }
173
+ if (integrationInstance.status === 'DISABLED') {
174
+ console.warn(
175
+ `[${integrationClass.Definition.name}] Integration ${params.data.integrationId} is DISABLED. Discarding ${params.event} message.`
176
+ );
177
+ return;
178
+ }
167
179
  } else {
168
180
  // Instantiates a DRY integration class without database records.
169
181
  // There will be cases where we need to use helpers that the api modules can export.
@@ -186,6 +198,19 @@ const createQueueWorker = (integrationClass) => {
186
198
  `Error in ${params.event} for ${integrationClass.Definition.name}:`,
187
199
  error
188
200
  );
201
+
202
+ // 4xx HTTP errors are permanent — the requester already
203
+ // attempted token refresh (401) and backoff (429/5xx).
204
+ // By the time a 4xx reaches here, retrying won't help.
205
+ // 408 (timeout) and 429 (rate limit) are excluded — both are transient.
206
+ const status = error.statusCode;
207
+ if (status && status >= 400 && status < 500 && status !== 408 && status !== 429) {
208
+ error.isHaltError = true;
209
+ console.warn(
210
+ `[${integrationClass.Definition.name}] Permanent ${status} error for ${params.event} — message will be discarded (no retry)`
211
+ );
212
+ }
213
+
189
214
  throw error;
190
215
  }
191
216
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@friggframework/core",
3
3
  "prettier": "@friggframework/prettier-config",
4
- "version": "2.0.0-next.76",
4
+ "version": "2.0.0-next.78",
5
5
  "dependencies": {
6
6
  "@aws-sdk/client-apigatewaymanagementapi": "^3.588.0",
7
7
  "@aws-sdk/client-kms": "^3.588.0",
@@ -38,9 +38,9 @@
38
38
  }
39
39
  },
40
40
  "devDependencies": {
41
- "@friggframework/eslint-config": "2.0.0-next.76",
42
- "@friggframework/prettier-config": "2.0.0-next.76",
43
- "@friggframework/test": "2.0.0-next.76",
41
+ "@friggframework/eslint-config": "2.0.0-next.78",
42
+ "@friggframework/prettier-config": "2.0.0-next.78",
43
+ "@friggframework/test": "2.0.0-next.78",
44
44
  "@prisma/client": "^6.17.0",
45
45
  "@types/lodash": "4.17.15",
46
46
  "@typescript-eslint/eslint-plugin": "^8.0.0",
@@ -80,5 +80,5 @@
80
80
  "publishConfig": {
81
81
  "access": "public"
82
82
  },
83
- "gitHead": "5f03113234df57301443502f2751f1864dd44e73"
83
+ "gitHead": "c8e0c0c725a9e49b76d4e095927a443640bf9ec9"
84
84
  }