Skip to content

Commit

Permalink
SNOW-1801434-Add-GUID-to-request-in-NODE.js-driver: Add guid in async…
Browse files Browse the repository at this point in the history
… request
  • Loading branch information
sfc-gh-fpawlowski committed Dec 5, 2024
1 parent 08cc997 commit e9e96a2
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/services/sf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -733,20 +730,31 @@ 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
//TODO: this should be wrapped with the same operations, as in the synchronous send method's callback.
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.
*
Expand Down

0 comments on commit e9e96a2

Please sign in to comment.