graaljs icon indicating copy to clipboard operation
graaljs copied to clipboard

How to get stacktrace and/or linenumber from java in an async js function

Open cjaeriksson opened this issue 2 years ago • 3 comments

We have async js functions making calls into java-land to log events, with regular functions this works fine and I can get the linenumber of the calling script like this (if there's a better way I'd love to hear about that too):

            int line = -1;
            Throwable t = new RuntimeException();
            TruffleStackTrace.fillIn(t);
	    List<TruffleStackTraceElement> trace = TruffleStackTrace.getStackTrace(t);
	    for (TruffleStackTraceElement elm : trace) {
		Node node = elm.getLocation();
		if (node != null) {
		    line = node.getEncapsulatingSourceSection().getStartLine();
		    break;
		}
	    }

This however doesn't work in a callback from an async function, is it possible to do this and if so how ?

I'm using Temurin JDK 21 + Graal 23.1.1

cjaeriksson avatar Jan 17 '24 08:01 cjaeriksson

Hi, Thank you for reaching out, could you please share a full reproducer of the issue so we can look into it? Thank you

oubidar-Abderrahim avatar Feb 06 '24 15:02 oubidar-Abderrahim

Hi, any update?

oubidar-Abderrahim avatar Feb 21 '24 10:02 oubidar-Abderrahim

Hi sorry, been super busy - will try to get a reproducible case added here soon

cjaeriksson avatar Feb 21 '24 10:02 cjaeriksson

I'll close this ticket for inactivity. If you managed to get a reproducer please create a new ticket on this project or the main project: https://github.com/oracle/graal and we'll take a second look at it. Thank you

oubidar-Abderrahim avatar Apr 25 '24 13:04 oubidar-Abderrahim