Debugging Support for jsscripting?

I’m aware the topic is not exactly new in the forum… but reading a little bit about GraalVM, it seems it comes with decent debugging support: Chrome Debugger

Would it be possible to activate this functionality? Or did anyone already manage to get this to work?

1 Like

I’m definitely not an expert on this stuff but based on that link it looks to be potentially feasible to use the Programmatic Launch approach. But that would require changes to the JS Scripting add-on.

I’m not sure what other implecations there might be to setting break points might be. If a break point is hit does that just stop that one rule or all JS Scripting rules? To avoid that would each individual rule need it’s own debugging port/web server (which probably isn’t feasible)? What sort of increased resources are required to run with debugging enabled?

All these will need some research.

Definitely file an issue on the openhab-addons repo tagging JS Scripting.

1 Like

Thanks, Rich!

I appreciate it’s not trivial to embed debugging support in the add-on and fully agree the questions you raised need a thought-out answer.
Personally, I would say that if by default only rules with active breakpoints would be considered for debugging, it should be sufficient for most cases.

In any case I’ve created an issue as suggested: [jsscripting] Debugging Support · Issue #17415 · openhab/openhab-addons · GitHub

That could mean setting up a separate debug port per rule though. That’s what I’m afraid of. But I don’t know that’s the case. It might work reasonably but give that it’s embedded and multithreaded :person_shrugging: . Debugging with breakpoints sure would be nice though.

Thanks for opening the issue! I suspect Florian will have a look at it without too much of a delay.

This also what I think might be the case, given that the debugger has to be enabled per context and each script gets its own context.
Anyway I don’t think it is a good idea to enable the debugger by default, I think we should make it configurable when and for which script(s) to enable.

3 Likes

I think that is a nice compromise.