Compare View
Commits (3)
Changes
Showing 5 changed files Side-by-side Diff
CHANGELOG.md
... | ... | @@ -4,8 +4,15 @@ All notable changes to this project will be documented in this file. Dates are d |
4 | 4 | |
5 | 5 | Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). |
6 | 6 | |
7 | +#### [v1.46.4](https://gitlab.kodesumber.com/komodo/komodo-sdk/compare/v1.46.3...v1.46.4) | |
8 | + | |
9 | +- Fix eslint on coreapi [`7ba193c`](https://gitlab.kodesumber.com/komodo/komodo-sdk/commit/7ba193c55304775e75ccf8acf4e618413df897c1) | |
10 | +- Log pull task params [`57d148d`](https://gitlab.kodesumber.com/komodo/komodo-sdk/commit/57d148d36c742819df90cb1dc36b1ab07e87bdf4) | |
11 | + | |
7 | 12 | #### [v1.46.3](https://gitlab.kodesumber.com/komodo/komodo-sdk/compare/v1.46.2...v1.46.3) |
8 | 13 | |
14 | +> 25 August 2025 | |
15 | + | |
9 | 16 | - Default data.detail to report is empty string [`e551a43`](https://gitlab.kodesumber.com/komodo/komodo-sdk/commit/e551a439df7c58eafe2f2a7ccc5d53ad258f05df) |
10 | 17 | |
11 | 18 | #### [v1.46.2](https://gitlab.kodesumber.com/komodo/komodo-sdk/compare/v1.46.1...v1.46.2) |
coreapi/index.js
1 | +const MODULE_NAME = 'KOMODO-SDK.COREAPI'; | |
2 | + | |
1 | 3 | const request = require('request'); |
2 | 4 | const logger = require('tektrans-logger'); |
3 | 5 | const coreUrl = require('../core-url'); |
... | ... | @@ -6,7 +8,11 @@ function isLogDisabled() { |
6 | 8 | return global.KOMODO_SDK_NO_LOG_ON_COREAPI; |
7 | 9 | } |
8 | 10 | |
9 | -isLogDisabled() || logger.verbose(`CORE URL: ${coreUrl}`); | |
11 | +if (!isLogDisabled()) { | |
12 | + logger.verbose(`${MODULE_NAME} 229BAC11: Initialized`, { | |
13 | + coreUrl, | |
14 | + }); | |
15 | +} | |
10 | 16 | |
11 | 17 | function doRequest(params, cb) { |
12 | 18 | return new Promise((resolve) => { |
... | ... | @@ -16,22 +22,36 @@ function doRequest(params, cb) { |
16 | 22 | qs: params.qs || null, |
17 | 23 | }; |
18 | 24 | |
19 | - isLogDisabled() || logger.verbose('Requesting to CORE', { | |
20 | - xid: params.xid, method: options.method, fullpath: options.url, qs: options.qs, | |
21 | - }); | |
25 | + if (!isLogDisabled()) { | |
26 | + logger.verbose(`${MODULE_NAME} 73C28396: Requesting to CORE`, { | |
27 | + xid: params.xid, method: options.method, fullpath: options.url, qs: options.qs, | |
28 | + }); | |
29 | + } | |
22 | 30 | |
23 | 31 | request(options, (err, res, body) => { |
24 | 32 | if (err) { |
25 | - isLogDisabled() || logger.warn(`COREAPI: Error doing HTTP ${options.method} to CORE. ${err.toString()}`, { xid: params.xid }); | |
26 | - | |
33 | + if (!isLogDisabled()) { | |
34 | + logger.warn(`${MODULE_NAME} 01738CB9: Error doing HTTP ${options.method} to CORE`, { | |
35 | + xid: params.xid, | |
36 | + eCode: err.code, | |
37 | + eMessage: err.message || err.toString(), | |
38 | + }); | |
39 | + } | |
40 | + | |
27 | 41 | resolve([err]); |
28 | 42 | if (typeof cb === 'function') cb(err); |
29 | 43 | return; |
30 | 44 | } |
31 | 45 | |
32 | 46 | if (res.statusCode !== 200) { |
33 | - const errStatusCode = new Error('COREAPI: CORE responded with non HTTP STATUS CODE 200'); | |
34 | - isLogDisabled() || logger.warn(`COREAPI: CORE returning HTTP STATUS CODE ${res.statusCode}, not 200`, { xid: params.xid, body }); | |
47 | + const errStatusCode = new Error(`${MODULE_NAME} 39685CF2: CORE responded with non HTTP STATUS CODE 200`); | |
48 | + if (!isLogDisabled()) { | |
49 | + logger.warn(errStatusCode, { | |
50 | + xid: params.xid, | |
51 | + httpStatus: res.statusCode, | |
52 | + body, | |
53 | + }); | |
54 | + } | |
35 | 55 | |
36 | 56 | resolve([errStatusCode]); |
37 | 57 | if (typeof cb === 'function') cb(errStatusCode); |
... | ... | @@ -43,7 +63,7 @@ function doRequest(params, cb) { |
43 | 63 | bodyObject = JSON.parse(body); |
44 | 64 | } catch (e) { |
45 | 65 | const errNoJson = new Error('COREAPI: CORE responded with non JSON body'); |
46 | - isLogDisabled() || logger.verbose(errNoJson, {body}); | |
66 | + if (!isLogDisabled()) logger.verbose(errNoJson, { body }); | |
47 | 67 | |
48 | 68 | resolve([errNoJson, body]); |
49 | 69 | if (typeof cb === 'function') cb(errNoJson, body); |
gateway/pull.js
... | ... | @@ -293,6 +293,8 @@ function forwardCoreTaskToPartner(coreMessage, startTime, xid) { |
293 | 293 | }); |
294 | 294 | } |
295 | 295 | |
296 | +let lastPullPayload; | |
297 | + | |
296 | 298 | const pullTask = async () => { |
297 | 299 | if (isPaused()) { |
298 | 300 | if (IS_DEBUG) { |
... | ... | @@ -343,7 +345,7 @@ const pullTask = async () => { |
343 | 345 | |
344 | 346 | const xid = uniqid(); |
345 | 347 | |
346 | - const params = new URLSearchParams({ | |
348 | + const paramsObj = { | |
347 | 349 | handler: config.handler_name, |
348 | 350 | products: (config.products || []).join(','), |
349 | 351 | locations: config.locations && config.locations.length ? config.locations.join(',') : 'ALL', |
... | ... | @@ -362,7 +364,17 @@ const pullTask = async () => { |
362 | 364 | ) || null, |
363 | 365 | komodosdk_type: matrix.komodosdk_type, |
364 | 366 | komodosdk_version: matrix.komodosdk_version, |
365 | - }); | |
367 | + }; | |
368 | + | |
369 | + const params = new URLSearchParams(paramsObj); | |
370 | + const paramsInString = params.toString(); | |
371 | + if (paramsInString !== lastPullPayload) { | |
372 | + lastPullPayload = paramsInString; | |
373 | + logger.info(`${MODULE_NAME} 3D954E60: Will pull task from core with this params`, { | |
374 | + xid, | |
375 | + paramsObj, | |
376 | + }); | |
377 | + } | |
366 | 378 | |
367 | 379 | const startTime = new Date(); |
368 | 380 | try { |
package-lock.json
1 | 1 | { |
2 | 2 | "name": "komodo-sdk", |
3 | - "version": "1.46.3", | |
3 | + "version": "1.46.4", | |
4 | 4 | "lockfileVersion": 2, |
5 | 5 | "requires": true, |
6 | 6 | "packages": { |
7 | 7 | "": { |
8 | 8 | "name": "komodo-sdk", |
9 | - "version": "1.46.3", | |
9 | + "version": "1.46.4", | |
10 | 10 | "license": "ISC", |
11 | 11 | "dependencies": { |
12 | 12 | "array-unique": "^0.3.2", |