Stipple.jl icon indicating copy to clipboard operation
Stipple.jl copied to clipboard

Stacktrace in function inside on() does not propagate back to stdout/stderr

Open szafna opened this issue 4 years ago • 8 comments

Hi, I have a small stipple reactive app. It is really nice and reactive and responsive framework. I have observers and use on() function. There are some functions from my package inside on() function. I've found out if there is an error somewhere in my function, error/stacktrace is not get propagated back to stdout/stderr. Execution of on() function just silently breaks - returns out of on() function. Is there a way to get these errors to stdout/err? Probably I have just missed obvious settings or pattern?

szafna avatar Dec 22 '20 16:12 szafna

Hi!

This is implemented using Observables.jl - I'm not sure if it provides any API for bubbling the exceptions into the main thread. It would be interesting though.

essenciary avatar Dec 29 '20 18:12 essenciary

Hi, @essenciary I've did some additional tests and found out: -if observables is changed in REPL - ex: myobject.data[]="something", stacktrace is written to stdout/stderr -if observables is changed in browser, stacktrace is not written to stdout/stderr Could this be related with threading in Stipple?

szafna avatar Jan 18 '21 11:01 szafna

Ah, interesting, thanks for the update. I presume that when done in the REPL the change is performed in the main thread and the exceptions bubble up. But possibly when done through the framework the updates go through a separate thread and they don't bubble up in the main thread. I need to check, I don't remember how things are set up.

essenciary avatar Jan 18 '21 12:01 essenciary

Yes! THis is killing me. Debugging is very hard. I have to go back to adding @info statements between every line. Is this due to @async to Genie using Threads? .. We had a similar issue is Remote Processes and had to add exception handling and logging.

cwiese avatar Nov 15 '21 01:11 cwiese

I agree 100%. I have three modes of workaround, depending on the level of difficulty.

  • sometimes it helps to just make the respective assignment at the REPL, e.g. model.button[] = true instead of pressing the button.
  • copy/paste the function block to an empty julia script, assign the varibiables as in the do block. Then, execute the script line by line
  • put the full do block in a function (possibly decorated with @noinline) and hook this function instead of a do-block. You can then easily call this function at the REPL and see what goes wrong.

The last version also makes your code nicely readable if your projects groes larger.

Happy coding :-)

hhaensel avatar Nov 15 '21 06:11 hhaensel

Sorry about this, I'll see if I can find a solution to rethrow the exception or show a dump of the error.

essenciary avatar Nov 15 '21 09:11 essenciary

@hhaensel the 4th workaround, I am aware, is to put in a try catch in on() do block.

szafna avatar Nov 15 '21 10:11 szafna

this is great tips .. thank you. I will post my fav. Also, I do remember having to put try/catched on remote_fetch functions and adding a logger.

cwiese avatar Nov 15 '21 12:11 cwiese