Skip to content

Errors in Polyglot API are not propagated correctly in Node #185

Open
@fniephaus

Description

@fniephaus

Describe the Bug

When using Polyglot.eval() from inside Graal-Node.js and an error occurs in either Python or Ruby as the execution language, the user sees a cryptic JS error message instead of the original error.

Steps to Reproduce

Python
$ node --jvm --polyglot
> result = Polyglot.eval('python', 'a + b')
TypeError: Cannot convert undefined or null to object: undefined
    at Function.defineProperties (native)
    ...
Ruby
$ node --jvm --polyglot
> result = Polyglot.eval('ruby', 'a + b')
TypeError: Object prototype may only be an Object or null: DynamicObject@28fe2bef<Method>
    at Function.setPrototypeOf (native)
    ...

Expected Behavior

An error native to the used execution language (Python or Ruby) should be shown signaling that the used variable a is not defined in the scope. See js for an example:

$ node --jvm --polyglot
> result = Polyglot.eval('js', 'a + b')
ReferenceError: a is not defined
    at <eval>:1:1
    at Object.eval (native)

Actual Behavior

A cryptic error message is shown.

Tested with GraalVM CE 19.0.0 on macOS.

/cc @jak-ing

Metadata

Metadata

Assignees

No one assigned

    Labels

    Node.jsRelevant for Graal.js' Node.js recastbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions