HTTP class getDebug method can be empty after a NetServer exception occurs

lock
push_pin
done
Besvart
3

Hi,

I noticed some weird behavior in one of our CRMScripts in SOD, and think I've pinpointed the issue, althoug I don't understand quite why it happens.

The problem is that when we have an instance of the HTTP class, then call save on an ExtraTable object, then the HTTP object gets messed up.

Here is a proof of concept script.

#setLanguageLevel 4;

HTTP http;
http.setDebugMode(true);
String response = String(http.post("https://whatever.requestcatcher.com"));

printLine(http.getDebug().getLength().toString());
printLine(http.getDebug().getLength().toString());

ExtraTable row = getExtraTable("y_temp");
row.save(); // This causes HTTP to reset 

printLine(http.getDebug().getLength().toString());
printLine(http.getDebug().getLength().toString());

When running this you'll see that the getDebug() method returns strings before saving the ExtraTable row, but has lost its info afterwards.

3861
3861
0
0

It doesn't behave like this in production, only in SOD. Issue seems to have come in the last month. I'm running "SuperOffice CRM Online 10.3 Build Release_10.3.4_2024.04.08-01" in SOD.

9. apr. 2024 | 08:36 a.m.

Alle Svar (3)

I was not able to reproduce this issue in my SOD tenant. 

I have sent you a message, so we can take a closer look at your site and see if there are any differences.

9. apr. 2024 | 09:57 a.m.

For anyone following this topic. The reason is found, and the change in debug info is caused by an exception happening in NetServer when calling row.save() (not a critical exception though). This exception causes the debug info to be cleared from the HTTP class. 

So, the best is to always get debug info right after having done the http call.

9. apr. 2024 | 11:59 a.m.

Thanks for troubleshooting Stian!

So in essence the .getDebug() method is only reliable immediately after making the HTTP call.

HTTP http;
http.setDebugMode(true);
String response = String(http.get(URL));
String debug = http.getDebug(); // Grab the string as soon as possible.

/* 
  * Doing anything here which might cause a NetServer exception can lead to getDebug() being cleared.
  * Because Service will internally use the HTTP class to report error to Application Insights, which will reuse the static variable used for holding debuginfo.
  */

String nogo = http.getDebug(); // This will be blank if a NetServer exception occured internally above here.

Great work, now we know and can work around the issue.

9. apr. 2024 | 12:26 p.m.

Legg til svar