Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
Auto-refreshing widgets leads to semaphore exhaustion - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • Auto-refreshing widgets leads to semaphore exhaustion
KB0634655

Auto-refreshing widgets leads to semaphore exhaustion


13032 Views Last updated : Jan 7, 2025 public Copy Permalink English (Original)
  • English (Original)
  • Japanese
KB Summary by Now Assist

Issue

Widgets using an auto-refresh mechanism may generate a very large number of requests to a REST API called /api/now/sp/rectangle. A very high number of these requests can lead to semaphore exhaustion on an instance. This is generally attributed to PRB956025 but often, it is really an issue with the portal implementation and can be relieved fairly easily.

Symptoms

  • A sudden increase in requests to /api/now/sp/rectangle/???
  • General slowness and an increase in 429 responses from the server

What is /api/now/sp/rectangle?

/api/now/sp/rectangle is a REST API used by Service Portal to facilitate communication between a widget’s controller and a server script. Specifically, this API is used whenever a widget calls server.update(), spUtil.update(), or similar functions to invoke the widget’s server script. The widget’s server script is where the data model is populated so this is often done to either update or refresh the data.

The Problem with auto-refreshing widgets

Service Portal was never designed with this use case in mind. Service Portal is a single page angular app and using methods like the standard javascript setInterval() function to create an auto-refresh actually creates a variable in the browser’s runtime that persists throughout the life of the angular app.

What happens, is that these timers are created in the browser’s runtime and every time a user navigates away from a page using an auto-refreshing widget and then back again, the timer is re-created. Now, there are two timers going for the same thing. Over time, a small number of users can unknowingly generate a very large number of these sp/rectangle calls just due to the fact that the old ones are never destroyed until leaving the portal altogether.

How to diagnose performance issues caused by auto-refreshing widgets

  1. Look for is that high number of calls to /api/now/sp/rectangle/???
  2. Find the widget making the call
    The API call provides that information. The request string contains the sys_id of a widget instance, sp _instance. A widget instance is a record mapping a widget to a page in the portal so it always contains a reference to the widget.
  3. Look for code to create an auto-refresh in the widget’s client script, or controller.

Most commonly, there is code like this:

setInterval(function(){
server.update();
},3000);

This tells the browser to call server.update() every 3 seconds.

There are some other variants possible as well, but they will all follow this pattern and make a call to the server at some interval or inside a loop.

How to reduce the number of calls

Reduce the number of calls by removing the code creating the auto-refresh. There may be more than one widget at fault so make sure to trace all of the sp/rectangle calls back to a widget and ensure they are all taken care of.

Since these are stored in the browser’s runtime, in some cases, the browser continues to send the requests regardless of whether the user’s session is active. If for example, the user goes home for the night but leaves the portal open on their desktop, the browser may continue to send those requests until the next morning.

Ultimately there is no perfect solution to keep the auto-refresh functionality and avoid performance issues but there are a few ideas that may help in the post from the community that this article was created from: Are your auto-refreshing widgets causing instance slowdowns?

Related Links

For more information also refer to these articles

KB0635134 - Resolving "Exhausted Default Semaphores" errors caused by Service Portal widgets having poorly defined record watcher (recordWatch) calls

KB0639111 - Fine-tuning Record Watchers in Service Portal


The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.