Skip to content

Commit 2480010

Browse files
committed
CLIS-88 Implement Retry for WFP Blocks Ignoring Error Causes
1 parent 3fa87c7 commit 2480010

File tree

6 files changed

+44
-36
lines changed

6 files changed

+44
-36
lines changed

Diff for: .eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"error",
2222
{ "allowWholeFile": true }
2323
],
24-
"eslint-comments/no-unused-disable": false,
24+
"eslint-comments/no-unused-disable": 0,
2525
"import/order": [
2626
"error",
2727
{ "newlines-between": "always", "alphabetize": { "order": "asc" } }

Diff for: package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "scanoss",
3-
"version": "0.10.3",
3+
"version": "0.10.4",
44
"description": "The SCANOSS JS package provides a simple, easy to consume module for interacting with SCANOSS APIs/Engine.",
55
"main": "build/main/index.js",
66
"typings": "build/main/index.d.ts",

Diff for: src/sdk/scanner/Dispatcher/DispatchableItem.ts

+18-13
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,30 @@ export class DispatchableItem {
1515

1616
private sbomMode: SbomMode;
1717

18-
private _uuid: string;
1918
constructor() {
2019
this.errorCounter = 0;
2120
this.form = new FormData();
2221
}
2322

24-
public getForm(): FormData {
25-
this.form.append('file', Buffer.from(this.fingerprintPackage.getContent()), 'data.wfp');
26-
if(this.engineFlags) this.form.append('flags', this.engineFlags);
23+
private _uuid: string;
24+
25+
public get uuid(): string {
26+
return this._uuid;
27+
}
28+
29+
public set uuid(uuid: string) {
30+
this._uuid = uuid;
31+
}
2732

28-
if(this.sbomMode && this.sbom) {
33+
public getForm(): FormData {
34+
this.form.append(
35+
'file',
36+
Buffer.from(this.fingerprintPackage.getContent()),
37+
'data.wfp'
38+
);
39+
if (this.engineFlags) this.form.append('flags', this.engineFlags);
40+
41+
if (this.sbomMode && this.sbom) {
2942
this.form.append('assets', this.sbom);
3043
this.form.append('type', this.sbomMode);
3144
}
@@ -57,12 +70,4 @@ export class DispatchableItem {
5770
this.sbom = sbom;
5871
this.sbomMode = sbomMode;
5972
}
60-
61-
public get uuid(): string {
62-
return this._uuid;
63-
}
64-
65-
public set uuid(uuid: string) {
66-
this._uuid = uuid;
67-
}
6873
}

Diff for: src/sdk/scanner/Dispatcher/Dispatcher.ts

+20-17
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export class Dispatcher extends EventEmitter {
124124
emitNoDispatchedItem(disptItem) {
125125
this.emit(
126126
ScannerEvents.DISPATCHER_LOG,
127-
`[ SCANNER ]: WFP content sended to many times. Some files won't be scanned`
127+
`[ SCANNER ]: WFP content sended to many times`
128128
);
129129
this.emit(ScannerEvents.DISPATCHER_ITEM_NO_DISPATCHED, disptItem);
130130
}
@@ -136,25 +136,28 @@ export class Dispatcher extends EventEmitter {
136136
error.name = 'TIMEOUT';
137137
}
138138

139-
if (this.recoverableErrors.has(error.name)) {
140-
disptItem.increaseErrorCounter();
141-
if (
142-
disptItem.getErrorCounter() >=
143-
this.scannerCfg.MAX_RETRIES_FOR_RECOVERABLES_ERRORS
144-
) {
145-
this.emitNoDispatchedItem(disptItem);
146-
if (this.scannerCfg.ABORT_ON_MAX_RETRIES)
147-
this.emitUnrecoberableError(error, disptItem, response);
148-
return;
139+
disptItem.increaseErrorCounter();
140+
if (
141+
disptItem.getErrorCounter() >=
142+
this.scannerCfg.MAX_RETRIES_FOR_RECOVERABLES_ERRORS
143+
) {
144+
this.emitNoDispatchedItem(disptItem);
145+
146+
if (this.scannerCfg.ABORT_ON_MAX_RETRIES) {
147+
error[
148+
'max_retries'
149+
] = `Fingerprint block retried ${this.scannerCfg.MAX_RETRIES_FOR_RECOVERABLES_ERRORS} times, aborting`;
150+
this.emitUnrecoberableError(error, disptItem, response);
149151
}
150-
this.emit(
151-
ScannerEvents.DISPATCHER_LOG,
152-
`[ SCANNER ]: Recoverable error happened sending WFP content to server. Reason: ${error}`
153-
);
154-
this.dispatchItem(disptItem);
152+
155153
return;
156154
}
157-
this.emitUnrecoberableError(error, disptItem, response);
155+
this.emit(
156+
ScannerEvents.DISPATCHER_LOG,
157+
`[ SCANNER ]: An error occurred while sending WFP content to the server. Reason: ${error}`
158+
);
159+
this.dispatchItem(disptItem);
160+
return;
158161
}
159162
}
160163

Diff for: src/sdk/scanner/ScannerCfg.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class ScannerCfg extends BaseConfig {
1414
public IGNORE_CERT_ERRORS = false;
1515

1616
// Level of concurrency
17-
public CONCURRENCY_LIMIT = 10;
17+
public CONCURRENCY_LIMIT = 5;
1818

1919
// Timeout for each transaction
2020
public TIMEOUT = 180000;
@@ -29,7 +29,7 @@ export class ScannerCfg extends BaseConfig {
2929
// the winnowing algorithm will report a ScannerEvents.WINNOWING_STATUS event.
3030
public WINNOWING_REPORT_STATUS_AFTER_X = 10;
3131

32-
public MAX_RETRIES_FOR_RECOVERABLES_ERRORS = 5;
32+
public MAX_RETRIES_FOR_RECOVERABLES_ERRORS = 6;
3333

3434
public ABORT_ON_MAX_RETRIES = true;
3535

0 commit comments

Comments
 (0)