Skip to content

catch ruby exception (raised in attached function) within JS: change in behaviour #357

@pascalbetz

Description

@pascalbetz

Hi Mini Racer team.

We've run into an issue with MiniRacer and are wondering if we were relying on a undocumented feature or if this is a bug in more recent versions.

We used to be able to catch exception thrown in attached ruby functions inside a JS catch block. The ruby exception was "converted" to a JS exception.

Running this ruby script

require "mini_racer"
context = MiniRacer::Context.new
context.attach("externalFunction", proc { raise "raised in ruby"} )
result = context.eval(<<~JS)
  try {
    externalFunction()
  } catch(error) {
   "catch in JS"
  }
JS

gives me different results starting with 0.17.0.pre6

mini_racer-0.17.0.pre5 (and in all version since at least 0.12.0)

"catch in JS"

mini_racer-0.17.0.pre6

demo.rb:3:in 'block in <main>': raised in ruby (RuntimeError)
	from bla.rb:4:in 'MiniRacer::Context#eval'
	from bla.rb:4:in '<main>'

Is this not supported anymore?

We found this issue #44 from 2016, which discusses this feature and then got closed.
I tried versions down to 0.5.0 where it works. In versions before this i get segfaults or have issues installing.

Thanks for your help and have a nice day.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions