Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Instanceof regression when updating to Zurich

anthonydian
Tera Contributor

Hello team!

 

We're encountering a strange error while deploying our app using now-sdk cli since Zurich (the issue wasn't present on Xanadu). 

The issue is related to the usage of "instanceof" (and possibly realted to file paths aswell) when throwing a custom Error and catching it in another file.

This WILL NOT trigger the error :

 - /src/server/Service.ts => throw a new FunctionalException (which extends the standard Error class)

 - /src/server/Controller => catch this exception, print the instanceof the error: "instanceof FunctionalException = true"

This WILL trigger the error :

 - /src/server/services/Service.ts => throw a new FunctionalException (which extends the standard Error class) : notice that this script is located on level below Controller.ts from the project root

 - /src/server/Controller.ts => catch this exception, print the instanceof the error: "instanceof FunctionalException = false"

 

To illustrate the issue, i created a now-sdk 4 demo project that you'll find as attachment.

This demo project expose a Scripted Rest API (using Fluent). One http endpoint will throw and catch an error correctly (GET <hostname>/api/x_frt_errordemo/v1/trigger_boum_demo/api/boum/ok), the other one will trigger the issue (GET <hostname>/api/x_frt_errordemo/v1/trigger_boum_demo/api/boum/ko).

anthonydian_0-1763456938882.png

-> DemoController will catch any exception and print the instanceof of the catched error

-> Service.ts will throw a FunctionalException (Service.ts is located on the same level as DemoController.ts)

-> SubService.ts will throw the same FunctionalException (SubService.ts is located one level deeper than DemoController).

 

If you need more details, do not hesitate!

 

Thanks for your time!
Best regards,

Anthony

 

2 REPLIES 2

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @anthonydian 

I would say that since this issue is coming from an upgrade, it’s better to log a support case with ServiceNow.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

anthonydian
Tera Contributor

Hi @Dr Atul G- LNG and thanks for your time!

 

A support case has already been created, but I also wanted to know if the community ever faced a similar issue :)!