@jsforce/jsforce-node 3.10.7 → 3.10.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/VERSION.d.ts +1 -1
- package/lib/VERSION.js +1 -1
- package/lib/http-api.js +16 -4
- package/lib/request.js +5 -2
- package/package.json +1 -1
package/lib/VERSION.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "3.10.
|
|
1
|
+
declare const _default: "3.10.9";
|
|
2
2
|
export default _default;
|
package/lib/VERSION.js
CHANGED
package/lib/http-api.js
CHANGED
|
@@ -226,10 +226,22 @@ class HttpApi extends events_1.EventEmitter {
|
|
|
226
226
|
* @protected
|
|
227
227
|
*/
|
|
228
228
|
isSessionExpired(response) {
|
|
229
|
-
//
|
|
230
|
-
//
|
|
231
|
-
|
|
232
|
-
|
|
229
|
+
// REST API status codes: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/errorcodes.htm
|
|
230
|
+
//
|
|
231
|
+
// "401 - The session ID or OAuth token used has expired or is invalid. The response body contains the message and errorCode."
|
|
232
|
+
if (response.statusCode === 401) {
|
|
233
|
+
// Known list of 401 responses that shouldn't be considered as "session expired".
|
|
234
|
+
//
|
|
235
|
+
// These usualy come from an CA/ECA, OAuth, IP restriction change in the org that block connections, we need to skip these
|
|
236
|
+
// org jsforce will enter into an infinite loop trying to get a valid token.
|
|
237
|
+
const responsesToSkip = ['Connected app is not attached to Agent', 'This session is not valid for use with the REST API'];
|
|
238
|
+
for (const p of responsesToSkip) {
|
|
239
|
+
if (response.body.includes(p))
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
return false;
|
|
233
245
|
}
|
|
234
246
|
/**
|
|
235
247
|
* Detect error response
|
package/lib/request.js
CHANGED
|
@@ -166,14 +166,17 @@ async function startFetchRequest(request, options, input, output, emitter, count
|
|
|
166
166
|
}
|
|
167
167
|
};
|
|
168
168
|
let res;
|
|
169
|
-
// Timeout after
|
|
169
|
+
// Timeout after 30 minutes without a response
|
|
170
170
|
//
|
|
171
171
|
// node-fetch's default timeout is 0 and jsforce consumers can't set this when calling `Connection` methods so we set a long default at the fetch wrapper level.
|
|
172
|
-
const fetchTimeout = options.timeout ??
|
|
172
|
+
const fetchTimeout = options.timeout ?? 1800000;
|
|
173
173
|
try {
|
|
174
174
|
res = await (0, request_helper_1.executeWithTimeout)(fetchWithRetries, fetchTimeout, () => controller.abort());
|
|
175
175
|
}
|
|
176
176
|
catch (err) {
|
|
177
|
+
if (err instanceof node_fetch_1.AbortError) {
|
|
178
|
+
err.message += ' Request was aborted due to timeout of 10 minutes.';
|
|
179
|
+
}
|
|
177
180
|
emitter.emit('error', err);
|
|
178
181
|
return;
|
|
179
182
|
}
|