The CreatorCon Call for Content is officially open! Get started here.

RESTResponseV2 async timeout

Che Pazzo
ServiceNow Employee
ServiceNow Employee

I am running an async execution of sn_ws.RESTMessageV2:

var request = new sn_ws.RESTMessageV2(name, method);

var response = request.executeAsync();

response.waitForResponse(60);

In this case, if the response takes longer than 60s, it throws a `com.glide.ecc.ECCResponseTimeoutException` error. This is *not* a standard javascript Error object (e.g. it uses `class` instead of `name`).

Is there any documentation anywhere about this? The best I can find is in the Scripting Outbound REST doc that reads: "Might throw exception timing out waiting for response in ECC queue.", which isn't very helpful.

A walk through the properties shows the following list, so I can piece together how to handle them, but if there is actual documentation out there, that would be better.

properties:

  • getClass
  • wait
  • localizedMessage
  • printStackTrace
  • getLocalizedMessage
  • notifyAll
  • initCause
  • getMessage
  • cause
  • message
  • getCause
  • notify
  • addSuppressed
  • setStackTrace
  • getStackTrace
  • hashCode
  • equals
  • toString
  • getSuppressed
  • stackTrace
  • suppressed
  • class
  • fillInStackTrace

thanks,

-MikeB

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Mike,



There are some default quota rules


Check these links -> Transaction Quotas - ServiceNow Wiki


How to set REST outbound timeout in Eureka



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Ankur,



I'm not looking to control the timeouts, but rather to catch and handle the exception that is thrown.



-MikeB


Hi Mike,



Use try catch block as below


and check



try {


var request = new sn_ws.RESTMessageV2(name, method);  


var response = request.executeAsync();  


response.waitForResponse(60);


}


catch(ex) {


var message = ex.getMessage();


}



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Ankur,



I know how to catch errors, but I'm looking for documentation on this error, specifically.


e.g. I can identify this error with:


if (ex.getClass() == 'class com.glide.ecc.ECCResponseTimeoutException') {
  do('deal with this, maybe try again');
}

The problem is that pretty much *every other* error uses `name`, while this one uses class. This is a problem when the error could just as easily have been a ReferenceError, for which `getClass()` would return `undefined`. In short, it's different from a normal Error object, so I would expect that it should be documented somewhere.



The REST V2 doc specifically mention that an exception might be thrown. I'm looking for the docs on this exception.


e.g. What does `getClause` do?


e.g. What other exceptions are there? is it just the ECC Timeout?


e.g. What is the meaning of `wait` in the context of an exception that has already been thrown?



-MikeB