-
Notifications
You must be signed in to change notification settings - Fork 290
Description
I'm currently using ExecJS to allow mini scripts to be written in a backoffice, to create small functions that can convert an input value into another.
While using Duktape worked wonders, it doesn't support recent JS syntax (like string interpolation, String.prototype.padStart, etc), I switched to MiniRacer to avoid using an external runtime.
I am now facing the following error :
JS script
function transform(value) {
return value
}
Ruby code
def run(value)
ExecJS.runtime = ExecJS::Runtimes::MiniRacer
ctx = ExecJS.compile('')
ctx.call(js_code, value)
end
Exception
JSON::GeneratorError: NaN not allowed in JSON
This seems linked to the fact that input values are sent as JSON in MiniRacerRuntime, see
execjs/lib/execjs/mini_racer_runtime.rb
Line 33 in 5f78865
# TODO optimise generate |
Would there be any other way to improve the situation ? I'm open to using another interpreter, but keeping a recent enough dialect of JS + disallowing external runtime seems to limit the choices only to MiniRacer (unless you are running ruby truffle)
Thanks!