node.js – js_of_ocaml calling a function in ocaml from js

I have a function that uses a mutable variable that takes strings and returns strings. (its a read eval print loop interpreter)

I tried exporting it as such:

let () =
  Js.export_all
  (object%js
    method js_run_repl = Js.wrap_callback js_run_repl
  end)

Heres a snippet of the function im exporting

let js_run_repl str =
  match String.(compare str "quit") with
  | 0 -> "bye"
  | _ -> ...

regardless of my input it always returns bye, calling the function directly in ocaml produced the expected behaviour. Heres the output from node:

> var mod = require('./main.bc');
undefined
> mod.js_run("constant P : Prop");
MlBytes { t: 0, c: 'bye', l: 3 }
> 

Its also peculiar why the function is called js_run instead of js_run_repl. the latter is undefined according to node.