From e9e96a2881ad6bdf6e783da9c20d99183c3446a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Paw=C5=82owski?= Date: Thu, 5 Dec 2024 04:26:25 +0100 Subject: [PATCH] SNOW-1801434-Add-GUID-to-request-in-NODE.js-driver: Add guid in async request --- lib/services/sf.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/services/sf.js b/lib/services/sf.js index 0f62776ef..a1b26edfe 100644 --- a/lib/services/sf.js +++ b/lib/services/sf.js @@ -587,10 +587,7 @@ function StateAbstract(options) { const params = requestOptions.params || {}; if (requestOptions.includeGuid) { - // In case of repeated requests for the same request ID, - // the Global UID is added for better traceability. - const guid = uuidv4(); - params[sfParams.paramsNames.SF_REQUEST_GUID] = guid; + addGuidToParams(params); } const realRequestOptions = @@ -733,13 +730,17 @@ function StateAbstract(options) { // pre-process the request options this.preprocessOptions(this.requestOptions); + const params = this.requestOptions.params || {}; + if (this.requestOptions.includeGuid) { + addGuidToParams(params); + } const options = { method: this.requestOptions.method, headers: this.requestOptions.headers, url: this.requestOptions.absoluteUrl, json: this.requestOptions.json, - includeGuid: this.requestOptions.includeGuid, + params: params }; // issue the async http request @@ -747,6 +748,13 @@ function StateAbstract(options) { return await httpClient.requestAsync(options); }; + function addGuidToParams(params) { + // In case of repeated requests for the same request ID, + // the Global UID is added for better traceability. + const guid = uuidv4(); + params[sfParams.paramsNames.SF_REQUEST_GUID] = guid; + } + /** * Sends out the request. *