GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Performance issues with connection::request() with HTTP 500 status, delays up to 16 seconds · Issue #1702 · jsforce/jsforce

Performance issues with connection::request() with HTTP 500 status, delays up to 16 seconds #1702

New issue
Copy link
New issue
Copy link
Open
Open
Performance issues with connection::request() with HTTP 500 status, delays up to 16 seconds#1702
Copy link
Labels
docsDocumentation

Description

@pjmlp
pjmlp
opened on May 22, 2025
Issue body actions

Hi,

I recently faced an issue while doing requests of the following way:

 const requestOptions: HttpRequest = {
      method: 'GET',
      url: `/services/apexrest/website/some-apex-endpoint/${data-id}`,
      headers: {
        'content-type': 'application/json',
      }
    };

   // ...... some code
 const response = await conn.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.

Activity

  1. cristiand391 commented on May 22, 2025

    @cristiand391
    cristiand391
    on May 22, 2025
    Contributor
    More actions

    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.

  2. cristiand391
    added
    more info needed
    on May 22, 2025
  3. pjmlp commented on May 23, 2025

    @pjmlp
    pjmlp
    on May 23, 2025
    Author
    More actions

    I had a go at it, this was the output redacted,

    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.

  4. cristiand391
    added
    docsDocumentation
    and removed
    more info needed
    on May 26, 2025
  5. cristiand391 commented on May 26, 2025

    @cristiand391
    cristiand391
    on May 26, 2025
    Contributor
    More actions

    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:

    https://github.com/forcedotcom/agents/blob/834b67ecd4e631a7a57d31da51069425379528ca/src/maybe-mock.ts#L184

    default retry opts:

    jsforce/src/request.ts

    Line 47 in 96a330b

    statusCodes: options.retry?.statusCodes ?? [420, 429, 500, 502, 503, 504],

    Maybe override just the statusCode array to pass the same defaults without 500? so you still get retries for other requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.