Skip to content

popdoc: add IEx session to wasm module (2/5) - #696

Open
mmietla wants to merge 1 commit into
mainfrom
popdoc-wasm-iex
Open

popdoc: add IEx session to wasm module (2/5)#696
mmietla wants to merge 1 commit into
mainfrom
popdoc-wasm-iex

Conversation

@mmietla

@mmietla mmietla commented Jul 23, 2026

Copy link
Copy Markdown
Member

Part 2/5 of the popdoc IEx integration. Part of #695

@mmietla
mmietla force-pushed the popdoc-wasm-iex branch 2 times, most recently from 1187124 to 1c8d2e0 Compare July 23, 2026 14:02
Base automatically changed from popdoc-js-split to main July 27, 2026 10:04
@mmietla
mmietla requested a review from jgonet July 27, 2026 10:05
Comment thread popdoc/wasm/lib/iex_session.ex Outdated
@@ -0,0 +1,131 @@
defmodule PopdocWasm.IexSession do

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread popdoc/wasm/lib/iex_session.ex Outdated
Comment on lines +65 to +69
defp parse_error(code) do
Code.string_to_quoted!(code)
rescue
err -> exception_to_error_map(err, "")
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@mmietla mmietla changed the title popdoc: add IEx session to wasm module popdoc: add IEx session to wasm module (2/5) Jul 27, 2026
Comment thread popdoc/wasm/lib/wasm.ex
Comment on lines +79 to +80
# 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

" and # a run that spans the navigation gets a clean "no active session" reject."

What does that mean 😭

Comment thread popdoc/wasm/lib/wasm.ex
Comment on lines +19 to +22
# 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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should run code under task supervisor instead? Docs don't recommend setting flags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants