provegard / ncdbg

A debugger for Nashorn that uses Chrome DevTools as frontend
BSD 3-Clause "New" or "Revised" License
31 stars 5 forks source link

fails to load Javascript files with Illegal character exception #101

Open Deepashreehg opened 5 years ago

Deepashreehg commented 5 years ago

Javascript files are not getting loaded. I'm getting below exception.

java.net.URISyntaxException: Illegal character in path at index 0: #138:9 at java.net.URI$Parser.fail(URI.java:2848) at java.net.URI$Parser.checkChars(URI.java:3021) at java.net.URI$Parser.parseHierarchical(URI.java:3105) at java.net.URI$Parser.parse(URI.java:3063) at java.net.URI.(URI.java:588) at com.programmaticallyspeaking.ncd.infra.ScriptURL$.create(ScriptURL.scala:67) at com.programmaticallyspeaking.ncd.nashorn.JDIExtensions$RichLocation$.scriptURL$extension(JDIExtensions.scala:53) at com.programmaticallyspeaking.ncd.nashorn.ScriptFactory.$anonfun$scriptUrlAndLocations$2(ScriptFactory.scala:62) at scala.util.Success.$anonfun$map$1(Try.scala:251) at scala.util.Success.map(Try.scala:209) at com.programmaticallyspeaking.ncd.nashorn.ScriptFactory.scriptUrlAndLocations(ScriptFactory.scala:57) at com.programmaticallyspeaking.ncd.nashorn.ScriptFactory.considerReferenceType(ScriptFactory.scala:39) at com.programmaticallyspeaking.ncd.nashorn.ClassScanner.considerReferenceType(ClassScanner.scala:159) at com.programmaticallyspeaking.ncd.nashorn.ClassScanner.scanOutstandingClasses(ClassScanner.scala:212) at com.programmaticallyspeaking.ncd.nashorn.ClassScanner.$anonfun$scanOutstandingClasses$1(ClassScanner.scala:218) at com.programmaticallyspeaking.ncd.nashorn.NashornDebuggerHost$$anon$2.$anonfun$onNext$1(NashornDebuggerHost.scala:180) at com.programmaticallyspeaking.ncd.nashorn.NashornDebuggerHost$$anon$2.$anonfun$onNext$1$adapted(NashornDebuggerHost.scala:180) at com.programmaticallyspeaking.ncd.nashorn.NashornDebugger.$anonfun$create$1(NashornDebugger.scala:58) at scala.concurrent.Future$.$anonfun$apply$1(Future.scala:654) at scala.util.Success.$anonfun$map$1(Try.scala:251) at scala.util.Success.map(Try.scala:209) at scala.concurrent.Future.$anonfun$map$1(Future.scala:288) at scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:29) at scala.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:29) at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60) at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402) at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

I have added few logs statements in ScriptFactory.scala at line nos 44, 60, 61, 66. I have attached the corresponding ncdbg.log file

ScriptFactory.scala.txt ncdbg.log

benoitcerrina commented 5 years ago

Note that the exception is:

java.net.URISyntaxException: Illegal character in path at index 0: <eval>#138:9<eval>
    at java.net.URI$Parser.fail(URI.java:2848)

when the issue was written the "tags" were escaped by markdown

provegard commented 5 years ago

Thanks for the report, I'll take a look!

provegard commented 5 years ago

I've added compensation for this. Could you please test the latest master? In particular, do the scripts show up in DevTools in a way that makes sense?

benoitcerrina commented 5 years ago

Hello, we are testing, the fix seems to work. We have a problem to make sense of which script is what but it might be due to a change in the way our infrastructure is loading the scripts into Nashorn (which might also be why the problem came to the surface anyway). We need a bit more time to see if there is anything which you could do any better.

provegard commented 5 years ago

Ok, let me know what you find.

provegard commented 5 years ago

Any update?

benoitcerrina commented 5 years ago

yes. I still don't know what changed but we have a good bypass. If we add //# sourceURL=script name to our scripts then the name is correctly picked up.

benoitcerrina commented 5 years ago

I haven't been able to successfully set breakpoints though: I get the following error: Setting an unresolved breakpoint with ID ndb1 at line 238 in script with URL xPlanDSLCCommandImplementation or Setting an unresolved breakpoint with ID ndb2 at line 109 in script with URL eval:///Script175

provegard commented 5 years ago

"Unresolved" means that the location isn't known yet, which typically happens when the function that contains the location hasn't yet been executed. But I suppose DevTools doesn't stop at the breakpoint? Does it show?

benoitcerrina commented 5 years ago

yes the breakpoints show and it doesn't stop. Note that my colleague who opened this bug doesn't face this issue so I am not sure why it happens to me

benoitcerrina commented 5 years ago

One of the differences is that I am doing remote debugging (through an ssh tunnel) while the server she is using is on the machine running the debugger

provegard commented 5 years ago

Hm, could be some sort of timing problem. Can you post part of a log where you see the "Unresolved" messages and some context?

benoitcerrina commented 5 years ago

ncdbg.log Hello, I uploaded the log. The breakpoint which should have been hit is the one set at 10:26:22.689 (note that in the log the name of the scrip is truncated, it should show up as xPlanDSLCCommandImplementation and shows correctly in chrome. It should have happened between 10:26:39:199 and 10:26:39.465 (based on the server time which may be off by some milliseconds compare to the client but we can assume that it is correct in the seconds range

benoitcerrina commented 5 years ago

Not sure what else to give in term of context.

provegard commented 5 years ago

Huh, sounds like #100, where Chrome/DevTools cuts off the URL so what gets sent to ncdbg isn't the correct URL. Did you remove the v8only parameter?

benoitcerrina commented 5 years ago

let me check on that

benoitcerrina commented 5 years ago

looks like it, sorry for that, since it is not printed in the url any more, I am guessing I have let chrome autocomplete my url. I did get some errors in the console but it stopped in the breakpoint. I attached the new log ncdbg.log Thanks again for your help and responsiveness

provegard commented 5 years ago

No worries, I'm glad we sorted that out! I'll take a look at the log errors.

provegard commented 5 years ago

Do you see the error in any particular situation?