You need to sign in to do that
Don't have an account?
Darryl Moyers 20
Code behaving differently (correctly) ONLY when Debug Logs are active
Hi All,
We've setup a reasonably straightforward Apex Class that's running via a Lightning Component. Happy to share the code, eventually, but we seem to have narrowed down the specific scope of our problem... and we're stumped.
When we run our code and attach a debug/trace... It works correctly. All logic performs desirably.
When we run our code without a debug/trace... It performs incorrectly. We're not hitting errors, but our hypothesis is that collections that should have had, say, 3 items in them (when the code works properly, and/or when we attach a debug log/trace) may only contain 1 when we don't do the debug.
Does the problem we're describing above sound familiar to anyone? Our suspicion is that the debug logs / traces are either slowing down the code execution (in a way that's desirable for our code...) or holding onto simple collection variables in a way that they normally wouldn't.
Nothing makes sense, but it is repeatable.
We're dealing with ~100 lines of Apex, 3 DML statements, and all code is properly bulkified. No callouts. Nothing asynchronous. Just vanilla.
When we run it with Debugs, it works fine; when we run it without debugs, it works incorrectly.
Any thoughts?
We've setup a reasonably straightforward Apex Class that's running via a Lightning Component. Happy to share the code, eventually, but we seem to have narrowed down the specific scope of our problem... and we're stumped.
When we run our code and attach a debug/trace... It works correctly. All logic performs desirably.
When we run our code without a debug/trace... It performs incorrectly. We're not hitting errors, but our hypothesis is that collections that should have had, say, 3 items in them (when the code works properly, and/or when we attach a debug log/trace) may only contain 1 when we don't do the debug.
Does the problem we're describing above sound familiar to anyone? Our suspicion is that the debug logs / traces are either slowing down the code execution (in a way that's desirable for our code...) or holding onto simple collection variables in a way that they normally wouldn't.
Nothing makes sense, but it is repeatable.
We're dealing with ~100 lines of Apex, 3 DML statements, and all code is properly bulkified. No callouts. Nothing asynchronous. Just vanilla.
When we run it with Debugs, it works fine; when we run it without debugs, it works incorrectly.
Any thoughts?
I see some existing bugs today for example: https://success.salesforce.com/issues_view?id=a1p3A000001RXPlQAO with a workaround
There is a strange phenomenon called Heisenbug. In computer programming, heisenbug is a classification of an unusual software bug that disappears or alters its behavior when an attempt to isolate it. When we try to recreate the bug or use a debugger, the error may change or even vanish.
-In most of the cases the issue does not occur when we set the debug level of Apex to FINEST.
-When we reduce the debug level and try to replicate the issue, we will be able to replicate the issue and capture the debug logs.
-Such issue seems to occur when there is an issue with collections (list, set or map) in apex.
So, to find the exact error we can try reducing the debug level and capture the debug logs. Once we get the exact error we can work on the fix.
One possible workaround until the error is fixed is to add a simple debug statement in the code and the issue never occurs.
Anudeep
All Answers
I have seen issues in the past where there could be overhead caused in terms of CPU time by having debug logs enabled. However, I have never come across something that would not work when debug logs /trace is not captured.
If this is reproducible, have you tried raising a case with Salesforce Support?
Thanks,
Anudeep
Thanks for the reply. Your thoughts echo ours. If anything, we'd expect the functionality to work the opposite of the way we describe.
We looked into logging a Case with Salesforce, but none of the categories make sense. There's not really anything related to development/code, that's what the forums are for.
Which Case category would you suggest?
Thank you,
Darryl
I see some existing bugs today for example: https://success.salesforce.com/issues_view?id=a1p3A000001RXPlQAO with a workaround
There is a strange phenomenon called Heisenbug. In computer programming, heisenbug is a classification of an unusual software bug that disappears or alters its behavior when an attempt to isolate it. When we try to recreate the bug or use a debugger, the error may change or even vanish.
-In most of the cases the issue does not occur when we set the debug level of Apex to FINEST.
-When we reduce the debug level and try to replicate the issue, we will be able to replicate the issue and capture the debug logs.
-Such issue seems to occur when there is an issue with collections (list, set or map) in apex.
So, to find the exact error we can try reducing the debug level and capture the debug logs. Once we get the exact error we can work on the fix.
One possible workaround until the error is fixed is to add a simple debug statement in the code and the issue never occurs.
Anudeep
That was exactly the bug we were hitting. Our code has been remedied and pushed live, just by adding a debug statement before the .contains() method is used on a List.
So, to be clear, the following was not working because of the Known Issue:
The commented line below fixed it:
Thank you again,
Darryl
desi status in hindi (https://www.thefameeverything.com/desi-status-in-hindi-top-90-best-attitude-status/)
oneboxhd (https://oneboxhd.me/) for movie