Tuesday, June 18, 2019

Re: Stack trace not showing correct line number

Line Number is only accurate if you compile with:

  <set-property name="compiler.stackMode" value="emulated" />
 
<set-configuration-property name="compiler.emulatedStack.recordLineNumbers" value="true" />
 
<set-configuration-property name="compiler.emulatedStack.recordFileNames" value="true" />


But it will double the size of your compiled JS file!!!

With:
<set-property name="compiler.stackMode" value="native" />

you will only get the line number of your method declaration (but not the exact line inside the method).

I have a demo project where you can play with that: https://gwt-storage-objectify.appspot.com

Basically what we do at work, is to compile the project twice (one time with emulated and one time with native).
By default we serve the native JS (that is smaller) but if a User faces an Exception, then at next reload we serve the emulated JS for this specific User so if an Exception happens again, we have the exact StackTrace.

Freddy


On Wednesday, June 19, 2019 at 12:19:30 AM UTC+10, Carl wrote:
We use source maps to log stack traces from the GWT client on the server

<set-property name="compiler.stackMode" value="native" />

<set-property name="compiler.useSourceMaps" value="true"/>

<set-property name="compiler.emulatedStack" value="true" />

<set-configuration-property name="compiler.emulatedStack.recordLineNumbers" value="true" />

<set-configuration-property name="compiler.emulatedStack.recordFileNames" value="true" />


and use StackTraceDeobfuscator to deobfuscate


private StackTraceDeobfuscator getStackTraceDeobfuscator(ServletContext servletContext) {

String relativeWebPath = "WEB-INF/deploy/appimpl/symbolMaps";

String symbolMapsDirectory = servletContext.getRealPath(relativeWebPath);

StackTraceDeobfuscator std = StackTraceDeobfuscator.fromFileSystem(symbolMapsDirectory);

return std;

}


which gives us this stack trace:


at java.lang.Throwable.Throwable(Throwable.java:58)

at java.lang.Exception.Exception(Exception.java:25)

at java.lang.RuntimeException.RuntimeException(RuntimeException.java:25)

at java.lang.NullPointerException.NullPointerException(NullPointerException.java:27)

at client.CustomMenu.simulateClientCrash(CustomMenu.java:3734)    <--- first line of method

at client.CustomMenu$12.onClick(CustomMenu.java:1686)

..


The problem is that the trace always gives us the first line of the method and not the line where the exception is thrown.


CustomMenu.java

3734  private void simulateClientCrash() {     <--- first line of method

3735      if (true) {

3736        throw new NullPointerException();     <--- exception is thrown

3737   }

3738  }


This is not a big deal if the method is short but can be quite a pain if the method is longer.


Why is this? Can it be fixed?

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/a3b5408b-438a-4000-b14c-c9a690c57415%40googlegroups.com.

No comments:

Post a Comment