popdoc: add IEx session to wasm module (2/5) - #696
Conversation
1187124 to
1c8d2e0
Compare
| @@ -0,0 +1,131 @@ | |||
| defmodule PopdocWasm.IexSession do | |||
There was a problem hiding this comment.
I kinda don't see point of this module. What it actually does? I feel like it adds a struct we don't need (we already have one for binding and env from what I remember and could only be PopcornWasm.Eval with eval functions).
There was a problem hiding this comment.
First I want to create an IexSession module to separate the session logic from the evaluation logic. Since both currently share some functionality, it would be cleaner to rename the existing module to PopcornEval and keep only the eval logic there imo.
| defp parse_error(code) do | ||
| Code.string_to_quoted!(code) | ||
| rescue | ||
| err -> exception_to_error_map(err, "") | ||
| end |
There was a problem hiding this comment.
What about:
defp parse_input(code) do
{:ok, Code.string_to_quoted!(code)}
rescue
_ in TokenMissingError -> :incomplete
err -> {:error, exception_to_error_map(err, "")}
end
and simplify eval?
| # Sent on SPA navigation: eval-block sessions never outlive their page, and | ||
| # a run that spans the navigation gets a clean "no active session" reject. |
There was a problem hiding this comment.
" and # a run that spans the navigation gets a clean "no active session" reject."
What does that mean 😭
| # Evaluated user code runs in this process; a crashing linked process | ||
| # (spawn_link, Task.async) must deliver an exit message instead of | ||
| # killing the session with all its bindings. | ||
| Process.flag(:trap_exit, true) |
There was a problem hiding this comment.
Maybe we should run code under task supervisor instead? Docs don't recommend setting flags.
Uh oh!
There was an error while loading. Please reload this page.