You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Performance issues with connection::request() with HTTP 500 status, delays up to 16 seconds #1702
I recently faced an issue while doing requests of the following way:
constrequestOptions: HttpRequest={method: 'GET',url: `/services/apexrest/website/some-apex-endpoint/${data-id}`,headers: {'content-type': 'application/json',}};// ...... some codeconstresponse=awaitconn.request(requestOptions);
If some-apex-endpoint returns a HTTP 500, the request() call can take up to 16 seconds to return. Adding the option { responseType: 'text' }has had no effect on reducing the execution time.
Replacing the code with a regular Javascript fetch() has reduced the execution back to a more sensible 200 ms average execution time.
can you set the JSFORCE_LOG_LEVEL=DEBUG env var to see jsforce logs?
jsforce does a retry with exponential backoff on 500 response so that might be the case.
DEBUG [http-api] <request> method=GET, url=https://salesforce-servername/services/apexrest/website/endpoint/data-id
DEBUG [fetch] retrying for the 1 time
DEBUG [fetch] reason: statusCode match
DEBUG [fetch] retrying for the 2 time
DEBUG [fetch] reason: statusCode match
DEBUG [fetch] retrying for the 3 time
DEBUG [fetch] reason: statusCode match
DEBUG [fetch] retrying for the 4 time
DEBUG [fetch] reason: statusCode match
DEBUG [fetch] retrying for the 5 time
DEBUG [fetch] reason: statusCode match
DEBUG [http-api] elapsed time: 16790 msec
DEBUG [http-api] <response> status=500, url=https://salesforce-servername/services/apexrest/website/endpoint/data-id
Maybe I missed the information on the documentation, is there any way to disable this retry behaviour?
The issue was discovered while dealing with a server that wrongly uses HTTP 500 to mean not found, thus it became quite visible.
Not doc'd yet, I'll keep this open to track documenting the retry options better.
You can't disable/customize retry options on requests done via conn.data/metadata/sobject/ etc helpers but the conn.request methods take a retry parameter where you can override the default retry options like this:
Activity
cristiand391 commentedon May 22, 2025
can you set the
JSFORCE_LOG_LEVEL=DEBUGenv var to see jsforce logs?jsforce does a retry with exponential backoff on 500 response so that might be the case.
pjmlp commentedon May 23, 2025
I had a go at it, this was the output redacted,
Maybe I missed the information on the documentation, is there any way to disable this retry behaviour?
The issue was discovered while dealing with a server that wrongly uses HTTP 500 to mean not found, thus it became quite visible.
cristiand391 commentedon May 26, 2025
Not doc'd yet, I'll keep this open to track documenting the retry options better.
You can't disable/customize retry options on requests done via
conn.data/metadata/sobject/etc helpers but theconn.requestmethods take a retry parameter where you can override the default retry options like this:https://github.com/forcedotcom/agents/blob/834b67ecd4e631a7a57d31da51069425379528ca/src/maybe-mock.ts#L184
default retry opts:
jsforce/src/request.ts
Line 47 in 96a330b
Maybe override just the
statusCodearray to pass the same defaults without500? so you still get retries for other requests.