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

Maximum call stack size exceeded at Object.defineProperty.value (**\waterline\model\lib\model.js:67:20) #5325

Closed
elennaro opened this issue Dec 24, 2015 · 1 comment

Comments

@elennaro
Copy link

Given:

model A:

module.exports = {

    attributes: {

        name: { type: 'string', required: true, size: 255 },
        description: { type: 'string', size: 1000 },
        //Relations
        b: { collection: 'b', through: 'c', via: 'a' },

    }
};

model B:

/* global sails, c, a, b, module */


module.exports = {

    attributes: {
        id: { type: 'datetime', primaryKey: true },
        start: { type: 'datetime', defaultsTo: new Date(1970, 0, 1, 12, 0) },
        end: { type: 'datetime', defaultsTo: new Date(1970, 0, 1, 16, 0, 0) },
        isTrue: { type: "boolean", required: true, defaultsTo: true },
        //Relations
        as: { collection: 'a', through: 'c', via: 'b' },
    }
};

model C:

module.exports = {

    attributes: {
        quantity: { type: 'integer' },
        //Relations
        a: { model: 'a', foreignKey: true, columnName: 'a_id' },
        b: { model: 'b', type: 'date', foreignKey: true, columnName: 'b_id' }
    }
};

test:

var assert = require('chai').assert,
        destroyCollections = require('../../../helper').destroyCollections;

describe('C', function () {
    var idOfC;
    before(function (done) {
        B.create({ id: DateTimeService.generateNowDate() })
                .then(function (newB) {
                    A.create({ name: "my new a" }).then(function (newA) {
                        C.create({ a_id: newA.id, b_id: newB.id, quantity: 12 }).then(function (newC) {
                            idOfC = newC.id;
                            done();
                        }).catch(done);
                    }).catch(done);
                }).catch(done);
    });

    after(function (done) {
        destroyCollections(A, B, C, done);
    });

    it('findOne()', function (done) {
        C.findOne(idOfC).then(function (result) {
            sails.log.info("Result of find one is", result);
            assert.equal(result.quantity, 12, "quantity decremented");
            done();
        }).catch(done);
    });

});

The error is:

RangeError: Maximum call stack size exceeded
    at Object.defineProperty.value (E:\tmp\assosiation\node_modules\waterline\lib\waterline\model\lib\model.js:67:20)
    at formatValue (util.js:215:21)
...
//repeated billion times
...
    at formatValue (util.js:217:13)
    at Object.inspect (util.js:107:10)
    at E:\tmp\assosiation\node_modules\captains-log\lib\write.js:65:22
    at Function.forEach (E:\tmp\assosiation\node_modules\captains-log\node_modules\lodash\dist\lodash.js:3297:15)
    at Function._writeLogToConsole [as info] (E:\tmp\assosiation\node_modules\captains-log\lib\write.js:55:5)
    at E:\tmp\assosiation\test\unit\test\models\C.test.js:25:14
    at tryCatcher (E:\tmp\assosiation\node_modules\waterline\node_modules\bluebird\js\main\util.js:26:23)
    at Promise._settlePromiseFromHandler (E:\tmp\assosiation\node_modules\waterline\node_modules\bluebird\js\main\promise.js:503:31)
    at Promise._settlePromiseAt (E:\tmp\assosiation\node_modules\waterline\node_modules\bluebird\js\main\promise.js:577:18)
    at Promise._settlePromises (E:\tmp\assosiation\node_modules\waterline\node_modules\bluebird\js\main\promise.js:693:14)
    at Async._drainQueue (E:\tmp\assosiation\node_modules\waterline\node_modules\bluebird\js\main\async.js:123:16)
    at Async._drainQueues (E:\tmp\assosiation\node_modules\waterline\node_modules\bluebird\js\main\async.js:133:10)
    at Immediate.Async.drainQueues [as _onImmediate] (E:\tmp\assosiation\node_modules\waterline\node_modules\bluebird\js\main\async.js:15:14)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

Here is the repository/branch to run the test: https://github.com/elennaro/assosiation-waterline/tree/error-find-one-assosiation

@particlebanana
Copy link
Contributor

Merged and published an updated version 0.10.30. Thanks @elennaro!

@raqem raqem transferred this issue from balderdashy/waterline May 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants