Background script running error

rdelpeso
Giga Guru

Hi,

Has anyone ran into this issue and know how to solve it?

When running a background script from VSCode using the ServiceNow extension I get this output in red:

Error in executing script!

 

find_real_file.png

The script I am running is trivial:

// Write your scripts here to run (JavaScript executed on server)
gs.error('test');
 
but no matter what script I use, it throws the same message every time.
 
This only happens in one of our instances. It works well in another of our instances. Any ideas?
Also, every other functionality of the extension works as intended, it is only the background script run that breaks.
 
Things I've tried:
- Rebooting PC
- Restarting VSCode
- Uninstall Extension
- Fresh VSCode installation
- Connecting to different instance (it works fine there)
- Syncing to several different applications (everything works, except background script)
- Used multiple different admin users
- Used multiple authentication methods
- Tried debugging VSCode itself (it goes into a worker blackbox)
- Tried debugging the source code of the extension (is all minimized and a true pain to read, so I gave up)
 
I suspect there is something on this instance that is preventing the background script action from acting. But I have no logs nor transaction logs of any kind to look at.
 
Both instances that i've tried are clones from the same main instance. (Main Instance -> Cloned over to DEV1 and DEV2 instances, DEV1 executes the background script just fine, DEV2 does not)
 
Thanks for your assistance.
1 ACCEPTED SOLUTION

Finally found the answer after digging through the extension minified source code (that was painful).

 

All users I was testing with, had "Password needs reset" set to true. Which forces the execution of "Background Scripts" to redirect (with 302) to "login_cpw.do".

 

The execution of Background Script relies on a special type of "POST" which does not go through the regular API. So, it attempts to authenticate as a normal user.

 

The extension does not make this easy to identify, giving a cryptic useless message. Solution was to simply change the password  or change the flag to false.

 

There goes part of my sanity for 2022 yay.

 

View solution in original post

5 REPLIES 5

Imi NOW
Tera Contributor

I have no flag "Password needs reset" set to true, even I've tried to change the password but still getting the error in one of our instances. Any other ideas?