jonathanperret / paysage

Paysage is a visual shared playground for code.
http://paysage.xyz
GNU Affero General Public License v3.0
19 stars 9 forks source link

Error reporting to user: what we should do #84

Open juliendorra opened 7 years ago

juliendorra commented 7 years ago

This issue is for defining a good user flow (from code to UI) for reporting errors in code objects back to the users using writing them collectively.

I'll update this top comment to reflect the feedbacks, proposals and comments in this issue thread.

Status

What kind of errors?

Limiting errors before sending

Good examples

Existing issues

We now have 3 issues that are related to error and error reporting, covering it from different angles :

User flow goals

We catch errors

We catch and stop the effects of as many types of errors affecting users as possible.

This might lead to using sandboxing strategies, AST manipulation, code rewriting, redefining functions, as we can learn from the CodePen and JSbin experience.

So we need to prioritize and try and do the easiest things that gives us the more useful coverage first.

We channel errors back to the Programmer page

There several ways to do that:

We point the user to the errors

We now need to direct the user to the source of the error. Possibilities from easiest to hardest to implement are:

Implementation

To be determined as we try it! :-)

CodePen, Khan CS, LiveCodeLab all have docs, posts, and code that we can learn from.

jonathanperret commented 7 years ago

An excellent summary! 👍

jonathanperret commented 7 years ago

Routing errors back on the WebSocket seems to me the logical thing to do, but my brain always explodes when I try to think of the best way to handle multiple simultaneous renderers.

Have you seen Rollbar? Not our exact use case but it could provide some inspiration.

juliendorra commented 7 years ago

As for handling multiple (identical) error message we could:


juliendorra commented 7 years ago

(Of course if we set it to null every time a new code is sent we will be always be comparing to either null or the same error message from other Playgrounds. Or is there edge cases where we would really compare an old message with a newer one?)

jonathanperret commented 7 years ago

I think it will be relatively easy to associate errors to their code objects. Keeping track of some kind of version identifier will be necessary to make sure only errors generated by the latest version are shown to the user (even then, the code may have changed since the last “go live”, but there’s only so much we can do).

What remains is that the multiple running instances of a single code object may encounter the same, or different errors while running. I guess we can just ignore duplicates and see what happens.

juliendorra commented 7 years ago

It would probably help to time stamp the code object server-side every time new code Ian received. That way the renderer can send the error back with the original time stamp, helping the server to disambiguate and be sure that it's from the last code for this code object Of course a hash of they text would help too, probably in a complementary way. That would also allow to report different errors from different browsers but coming from the same code, instead of just trashing them as duplicate or replacing the oldest with the newest.

jonathanperret commented 7 years ago

So, #95 should handle catching and attributing runtime errors, but matching them to a line number in the Processing source is going to be tricky. There isn't a line-per-line correspondence between the generated JS and the Processing code — even the order of the lines can change a lot when classes are involved. And the Processing.js compiler isn't smart enough to generate a source map, or even just source line markers.

I've toyed with adding line markers in the source before handing it to Processing.js: can't do it as comments since stripping comments is among the first things the compiler does. String literals are promising (as they are kept as-is in the generated source), but you can't insert them just anywhere, which would mean a first pass of analysis of the source to determine the safe places… 😓