Code execution different in debugger than non-debugger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2025 05:58 AM
I am facing a weired problem and I don't know how to solve it.
We integrate our monitoring system with the CMDB in ServiceNow. Meaning: we import daily updated infos in our CIs.
this process used to work with SOAP API. Now the provider of the monitoring solution added REST API (with JSON results) recently.
this is way more convenient to code/debug.
Now the issue:
I debug, the code runs fine, does exactly what it needs to to (on 1 device)
I execute the code without debugging and it produces to many records.
the "parsed" filtered JSON always looks fine in debugger.
as soon as I turn it off, it creates wonderful records I have no clue where those values come from.
the only, maybe weired thing i'm using:
an array of JSON I am filtering
array.filter(( item ) => (item.displayName == 'myTestValue' ))
Could it be that ServiceNow does not understand array.filter yet?
How come it runs just fine when I debug? Is then the JS Engine of my browser applied? I don't get it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2025 06:32 AM
I think I found the "bugger"... I was using optional chaining for JSON:
json.object?.person.hasOwnProperty
The usage of ?. turned on ECMAScript 2021 (ES12) mode and I didn't realize that..
so I changed, the code and now I can run the code just fine with "Execute Now" button