โ10-01-2020 10:26 AM
Iโm looking for General Guidance, not a solution to a specific problem!
I have a lot of experience programming in server-side languages like C++, C#, T-SQL, PL/SQL, and othersโฆ but am very much a newbie at Javascript. (When my employersโ pipelines use a Script snap, we solely use Javascript, not Python nor Ruby.)
How do other Snaplogic users debug the JS in their script snaps?
Iโve been largely just writing the equivalent of โprintโ statements by creating a debug object or a set of โtraceโ properties in the document stream. But thatโs a rather hamfisted and slow-going method for debugging.
I seem to recall that SnapLogic uses (used?) the Nashorn engine, but now that Snaplexes are on Java 11, is that still true? Thereโs the โNCDbgโ project on GitHub, which provides a debugger for Nashorn that can connect to Visual Studio Code (VSCode) as a front-endโฆ but it can only handle JS atop an underlying Java 8 or 9 JVM. Iโm wondering if there is something similar that would match up more closely with the SnapLogic engines and environment.
What do the rest of you do when you want to debug a script snap?
Thanks!
โ10-01-2020 10:47 AM
Yes, we still use the Nashorn engine for JavaScript. Itโs deprecated but still present in Java 11.
I canโt speak to how anyone debugs their JS scripts.
โ10-01-2020 10:51 AM
Thanks for the rapid reply!
Iโm hoping that a long-term Snaplogic user might chirp up with some phenomenally useful tricks that let me find problem code in our JS snaps and fix it.
โ10-01-2020 03:56 PM
For most transformations, the SnapLogic expression language can be used. We support dynamic validations, which enables rapid prototyping and development.
For more complex requirements, a custom Snap can be developed in Java. Full IDE support is possible through debugger support. A custom snap has performance advantages over a Script snap when the document count is large, but the development of the custom snap does require more effort.
For the Script snap, using log statement to debug the script is one approach. Another approach is to develop the script outside of SnapLogic, using the command-line version of the language to test the script and then upload the script into SnapLogic. This works well for Jython, I believe the same approach works for JavaScript.
โ10-02-2020 09:03 AM
Is there some other kind of logging available in JS besides adding extra โtraceโ properties to docs in the document stream?