Skip to content

Unexpected TypeError: Illegal invocation #262

@tahpot

Description

@tahpot

I have a strange problem, which unfortunately I can't isolate out of my actual code (sorry, I tried really hard!).

This code is being executed as Javascript within v8js:

// this works
var customer = r.getModel("customer", "65a704f8d138e4153e0044e7");
print(customer.name+"\n");

// this works
var office = customer.getRelated("office");
print(office.name+"\n");

// this doesn't work, it throws a TypeError: Illegal invocation
var address = office.getRelated("address");

Customer and office are both separate PHP objects that inherit from a common object that implements the getRelated() method.

Now, what doesn't make sense is office.getRelated is definitely an object with a getRelated() function:

var_dump(office.getRelated)

produces:

object(Closure)#1881690089 {
    function () { [native code] }
}

From my testing I can see the TypeError thrown in Javascript definitely halts execution as there is no debug tracing coming from the getRelated() method, eliminating a problem within the method.

The exact same code running on an old version of v8js (>6m old) and PHP5 works without any issue.

The code has another method getRelatedOne(). If I replace getRelated() in the code above with getRelatedOne(), the TypeError is still thrown however if I use getRelated() and then getRelatedOne(), the code works fine.

Is it possible there is some sort of memory issue with two objects sharing the same method definition?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions