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

'collections' of undefined at sails-postgresql adapter #78

Closed
jhereu opened this issue Sep 22, 2017 · 1 comment
Closed

'collections' of undefined at sails-postgresql adapter #78

jhereu opened this issue Sep 22, 2017 · 1 comment

Comments

@jhereu
Copy link

jhereu commented Sep 22, 2017

Hi,

We have a Sails app running with a sails-postgresql adapter. Since we installed [email protected] we ran into some compatibility issues between them. We have a config/autoreload.js file with the following content:

var watch = [
    'api/controllers',
    'api/models',
    'api/services',
    'api/policies',
    'api/responses',
    'api/blueprints',
    'config/locales',
    'config/routes.js',
    'config/cron.js',
    'config/custom.js',
    'config/policies.js'
];

module.exports['sails-hook-autoreload'] = {
    active: true,
    overrideMigrateSetting: false,
    usePolling: true,
    dirs: serializePaths(watch)
};

The overrideMigrateSetting is set to false, as we don't want the tables to be created again and so on. when we modify whichever file of the list, autoreload is triggered and does his job, but sails-postgresql crashes with the following error:

21/09/2017 | 11:26:53 | - error:  TypeError: Cannot read property 'collections' of undefined
    at getCollection (c:\Iberdrola\TicketBook\Node\ProyectoIncidencias\node_modules\sails-postgresql\lib\adapter.js:1354:39)
    at __CREATE__ (c:\Iberdrola\TicketBook\Node\ProyectoIncidencias\node_modules\sails-postgresql\lib\adapter.js:440:26)
    at after (c:\Iberdrola\TicketBook\Node\ProyectoIncidencias\node_modules\sails-postgresql\lib\adapter.js:1293:7)
    at c:\Iberdrola\TicketBook\Node\ProyectoIncidencias\node_modules\sails-postgresql\lib\adapter.js:1182:7
    at c:\Iberdrola\TicketBook\Node\ProyectoIncidencias\node_modules\sails-postgresql\node_modules\pg\lib\pool.js:84:11
    at dispense (c:\Iberdrola\TicketBook\Node\ProyectoIncidencias\node_modules\sails-postgresql\node_modules\pg\node_modules\generic-pool\lib\generic-pool.js:250:16)
    at Object.me.release (c:\Iberdrola\TicketBook\Node\ProyectoIncidencias\node_modules\sails-postgresql\node_modules\pg\node_modules\generic-pool\lib\generic-pool.js:349:5)
    at c:\Iberdrola\TicketBook\Node\ProyectoIncidencias\node_modules\sails-postgresql\node_modules\pg\lib\pool.js:88:20
    at c:\Iberdrola\TicketBook\Node\ProyectoIncidencias\node_modules\sails-postgresql\lib\adapter.js:1296:9
    at null.callback (c:\Iberdrola\TicketBook\Node\ProyectoIncidencias\node_modules\sails-postgresql\lib\adapter.js:234:15)
    at Query.handleReadyForQuery (c:\Iberdrola\TicketBook\Node\ProyectoIncidencias\node_modules\sails-postgresql\node_modules\pg\lib\query.js:89:10)
    at null.<anonymous> (c:\Iberdrola\TicketBook\Node\ProyectoIncidencias\node_modules\sails-postgresql\node_modules\pg\lib\client.js:163:19)
    at emitOne (events.js:82:20)
    at emit (events.js:169:7)
    at Socket.<anonymous> (c:\Iberdrola\TicketBook\Node\ProyectoIncidencias\node_modules\sails-postgresql\node_modules\pg\lib\connection.js:109:12)
    at emitOne (events.js:77:13)

It crashes once per model and we have 40+ models in our app. I understand by the error that "collection of undefined" refers to the global sails variable.

Also, in our app error log we can see those lines, printing our tables one by one:

TABLE --> table1
TABLE --> table2
TABLE --> ...

Those lines are printed by the function describe(connectionName, table, cb) inside the sails-postgresql adapter. Why is it describing all the tables and why does it not get printed when we start the node app for the first time?

// Describe a table
    describe: function(connectionName, table, cb) {
      spawnConnection(connectionName, function __DESCRIBE__(client, cb) {

        var connectionObject = connections[connectionName];
		console.error('TABLE --> ' + table);
        var collection = connectionObject.collections[table];
        var tableName = table;
        var schemaName = getSchema(connectionName, table);

Maybe this issue is more about the PostgreSQL adapter than the hook itself. Hope you can shed some light on this, as every time we reload a file, service for the users gets denied.

Thanks!

@jhereu
Copy link
Author

jhereu commented Sep 22, 2017

Ok, same issue as #60, sorry.

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

1 participant