diff --git a/README.md b/README.md index 60f9f05..1df8b7d 100644 --- a/README.md +++ b/README.md @@ -254,6 +254,7 @@ Configuration on the client side involves passing an object on startup, which ca * `LoginMechanism` - either `Default` or `Redirected`. If `Redirected` then authentication occurs through the injection of an additional screen, which contains the SASLogon prompt. This allows for more complex authentication flows (such as 2FA) and avoids the need to handle passwords in the application itself. The styling of the redirect flow can also be modified. If left at "Default" then the developer must capture the username and password and use these with the `.login()` method. * `useComputeApi` - Only relevant when the serverType is `SASVIYA`. If `true` the [Compute API](#using-the-compute-api) is used. If `false` the [JES API](#using-the-jes-api) is used. If `null` or `undefined` the [Web](#using-jes-web-app) approach is used. * `contextName` - Compute context on which the requests will be called. If missing or not provided, defaults to `Job Execution Compute context`. +* `requestHistoryLimit` - Request history limit. Increasing this limit may affect browser performance, especially with debug (logs) enabled. Default is 10. The adapter supports a number of approaches for interfacing with Viya (`serverType` is `SASVIYA`). For maximum performance, be sure to [configure your compute context](https://sasjs.io/guide-viya/#shared-account-and-server-re-use) with `reuseServerProcesses` as `true` and a system account in `runServerAs`. This functionality is available since Viya 3.5. This configuration is supported when [creating contexts using the CLI](https://sasjs.io/sasjs-cli-context/#sasjs-context-create). diff --git a/src/SASjs.ts b/src/SASjs.ts index 687e653..ce07b95 100644 --- a/src/SASjs.ts +++ b/src/SASjs.ts @@ -1034,7 +1034,8 @@ export default class SASjs { : RequestClient this.requestClient = new RequestClientClass( this.sasjsConfig.serverUrl, - this.sasjsConfig.httpsAgentOptions + this.sasjsConfig.httpsAgentOptions, + this.sasjsConfig.requestHistoryLimit ) } else { this.requestClient.setConfig( diff --git a/src/request/RequestClient.ts b/src/request/RequestClient.ts index 3e18632..208da39 100644 --- a/src/request/RequestClient.ts +++ b/src/request/RequestClient.ts @@ -56,6 +56,7 @@ export interface HttpClient { export class RequestClient implements HttpClient { private requests: SASjsRequest[] = [] + private requestsLimit: number = 10 protected csrfToken: CsrfToken = { headerName: '', value: '' } protected fileUploadCsrfToken: CsrfToken | undefined @@ -63,9 +64,11 @@ export class RequestClient implements HttpClient { constructor( protected baseUrl: string, - httpsAgentOptions?: https.AgentOptions + httpsAgentOptions?: https.AgentOptions, + requestsLimit?: number ) { this.createHttpClient(baseUrl, httpsAgentOptions) + if (requestsLimit) this.requestsLimit = requestsLimit } public setConfig(baseUrl: string, httpsAgentOptions?: https.AgentOptions) { @@ -149,7 +152,7 @@ export class RequestClient implements HttpClient { SASWORK: sasWork }) - if (this.requests.length > 20) { + if (this.requests.length > this.requestsLimit) { this.requests.splice(0, 1) } } diff --git a/src/types/SASjsConfig.ts b/src/types/SASjsConfig.ts index a40db2f..f366713 100644 --- a/src/types/SASjsConfig.ts +++ b/src/types/SASjsConfig.ts @@ -60,7 +60,7 @@ export class SASjsConfig { */ useComputeApi: boolean | null = null /** - * Optional settings to configure HTTPS Agent. + * Optional setting to configure HTTPS Agent. * By providing `key`, `cert`, `ca` to connect with server * Other options can be set `rejectUnauthorized` and `requestCert` */ @@ -69,6 +69,11 @@ export class SASjsConfig { * Supported login mechanisms are - Redirected and Default */ loginMechanism: LoginMechanism = LoginMechanism.Default + /** + * Optional setting to configure request history limit. Increasing this limit + * may affect browser performance, especially with debug (logs) enabled. + */ + requestHistoryLimit?: number = 10 } export enum LoginMechanism {