Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: 'set' on proxy: trap returned falsish for property #2

Open
asystat opened this issue May 17, 2021 · 1 comment
Open

TypeError: 'set' on proxy: trap returned falsish for property #2

asystat opened this issue May 17, 2021 · 1 comment

Comments

@asystat
Copy link

asystat commented May 17, 2021

Hello, I am trying to create a simple relation but I am getting this very uninformative error.

This is the code:

    let car = db.R.dispense('car');
    car.brand = 'Brand';
    car.model = 'Model';
    car.year = 'Model';
    car.chat_keyword= 'KWD';
    try {await db.R.store(car);}catch (e) {console.log(e);}

    console.log("Creating usercar model");
    let usercar = db.R.dispense('usercar');
    usercar.added_date = db.R.isoDate();
    usercar.car = car;
    try {await db.R.store(usercar);}catch (e) {console.log(e);}

Error:

TypeError: 'set' on proxy: trap returned falsish for property 'carId'
    at Proxy.<anonymous> (C:\Users\Perroloco\Programming\node\evsyscheduler\node_modules\redbean-node\dist\bean.js:187:57)
    at Generator.next (<anonymous>)
    at C:\Users\Perroloco\Programming\node\evsyscheduler\node_modules\redbean-node\dist\bean.js:14:71
    at new Promise (<anonymous>)
    at __awaiter (C:\Users\Perroloco\Programming\node\evsyscheduler\node_modules\redbean-node\dist\bean.js:10:12)
    at Proxy.storeTypeBeanList (C:\Users\Perroloco\Programming\node\evsyscheduler\node_modules\redbean-node\dist\bean.js:180:16)
    at RedBeanNode.<anonymous> (C:\Users\Perroloco\Programming\node\evsyscheduler\node_modules\redbean-node\dist\redbean-node.js:126:24)
    at Generator.next (<anonymous>)
    at C:\Users\Perroloco\Programming\node\evsyscheduler\node_modules\redbean-node\dist\redbean-node.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (C:\Users\Perroloco\Programming\node\evsyscheduler\node_modules\redbean-node\dist\redbean-node.js:4:12)
    at RedBeanNode.storeCore (C:\Users\Perroloco\Programming\node\evsyscheduler\node_modules\redbean-node\dist\redbean-node.js:124:16)
    at RedBeanNode.<anonymous> (C:\Users\Perroloco\Programming\node\evsyscheduler\node_modules\redbean-node\dist\redbean-node.js:116:35)
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\Perroloco\Programming\node\evsyscheduler\node_modules\redbean-node\dist\redbean-node.js:5:58)

Am I doing something wrong? thx

@louislam
Copy link
Owner

Thank you for trying the library.

After some investigations, it turns out it is a bug of "Magic Methods"
https://gist.github.com/loilo/4d385d64e2b8552dcc12a0f5126b6df8

 instanceHandler.set = (target, name, value, receiver) => {
    if (name in target) {
      Reflect.set(target, name, value, receiver)     // Bug here, it does not return anything!
    } else {
      return target.__set.call(target, name, value)
    }
  }

Will be fixed in the next version.
At this moment, you can remove this call "await db.R.store(car);" which you can bypass this error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants