@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 CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "3.10.7";
1
+ declare const _default: "3.10.9";
2
2
  export default _default;
package/lib/VERSION.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '3.10.7';
3
+ exports.default = '3.10.9';
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
- // TODO:
230
- // The connected app msg only applies to Agent API requests, we should move this to a separate SFAP/Agent API class later.
231
- return (response.statusCode === 401 &&
232
- !response.body.includes('Connected app is not attached to Agent'));
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 5 minutes without a response
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 ?? 300000;
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
  }
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "database.com"
11
11
  ],
12
12
  "homepage": "http://github.com/jsforce/jsforce",
13
- "version": "3.10.7",
13
+ "version": "3.10.9",
14
14
  "repository": {
15
15
  "type": "git",
16
16
  "url": "git://github.com/jsforce/jsforce.git"