-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededjavascriptPull requests that update Javascript codePull requests that update Javascript codemodel artefact management
Description
Is your feature request related to a problem? Please describe.
Implementation of BaseFileScanningConnector
's scan
method should have and use a configurable timeout option in case the service becomes unresponsive which would currently cause a scan to hang indefinitely.
Describe the solution you would like
Add a new connectors.fileScanners.scanTimeout: number
value config.ts
, used to control the maximum number of seconds that a scan should be awaited before timing out.
A possible implementation for the scan
implentation(s) could be:
function delay(ms: number) {
return new Promise((_, reject) => {
setTimeout(() => reject(new Error('Timeout exceeded')), ms);
});
}
// ...
await Promise.race([delay(config.connectors.fileScanners.scanTimeout * 1000), someScanFunction()]);
Describe alternatives you have considered
An alternative to the above could be to add a new BaseFileScanningConnector._scan
method and change BaseFileScanningConnector.scan
to call this e.g.
function delay(ms: number) {
return new Promise((_, reject) => {
setTimeout(() => reject(new Error('Timeout exceeded')), ms);
});
}
// ...
export abstract class BaseFileScanningConnector {
async scan(file: FileInterface): Promise<FileScanResult[]> {
return await Promise.race([delay(config.connectors.fileScanners.scanTimeout * 1000), this._scan(file)]);
}
abstract _scan(file: FileInterface): Promise<FileScanResult[]>
//...
}
However we do not currently enforce scan
to be async
so I am unsure on this approach in case there are synchronous BaseFileScanningConnector
implementaitons.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededjavascriptPull requests that update Javascript codePull requests that update Javascript codemodel artefact management