AdapterError: Connection is already registered

28 views
Skip to first unread message

Samuel Marks

unread,
Jul 8, 2016, 12:59:45 AM7/8/16
to sails.js

Writing a simple Waterline+restify scaffold in TypeScript. I recently modularised out all the bootstrapping code to a separate module+repository: restify-utils.

I have this simple teardown function:


import * as async from 'async'; export function tearDownConnections(connections, cb) { return connections ? async.parallel(Object.keys(connections).map( connection => connections[connection]._adapter.teardown ), cb) : cb() }


Which is called in the beforeAll and afterAll mocha blocks.

Specifically tearDownConnections is called in test_auth_api.ts#L25 and test_user_api.ts#L24.

Both test_auth_api.ts and test_user_api.ts succeed when run independently, however when running in the whole test directory with:


node restify_waterline_scaffold/node_modules/mocha/bin/_mocha --require ts-node/register --ui bdd --recursive restify_waterline_scaffold/test


I get this error:


AdapterError: Connection is already registered at Object.registerConnection (node_modules/waterline-postgresql/dist/adapter.js:120:53) at node_modules/waterline/lib/waterline.js:200:29 at node_modules/waterline/node_modules/async/lib/async.js:181:20 at Object.async.forEachOf.async.eachOf (node_modules/waterline/node_modules/async/lib/async.js:233:13) at Object.async.forEach.async.each (node_modules/waterline/node_modules/async/lib/async.js:209:22) at Array.async.auto.registerConnections (node_modules/waterline/lib/waterline.js:172:13) at node_modules/waterline/node_modules/async/lib/async.js:596:38 at _arrayEach (node_modules/waterline/node_modules/async/lib/async.js:85:13) at Object.async.auto (node_modules/waterline/node_modules/async/lib/async.js:554:9) at Waterline.initialize (node_modules/waterline/lib/waterline.js:118:9) at Object.strapFramework (node_modules/restify-utils/index.js:69:15) at test/api/user/test_user_api.js:21:52 at node_modules/async/dist/async.js:5285:13 at replenish (node_modules/async/dist/async.js:871:21) at node_modules/async/dist/async.js:877:29 at node_modules/async/dist/async.js:840:20 at node_modules/async/dist/async.js:5290:17 at node_modules/async/dist/async.js:339:31 at node_modules/async/dist/async.js:5293:13 at node_modules/async/dist/async.js:396:20 at replenish (node_modules/async/dist/async.js:858:28) at node_modules/async/dist/async.js:877:29 at node_modules/async/dist/async.js:840:20 at node_modules/async/dist/async.js:5290:17 at node_modules/async/dist/async.js:339:31 at node_modules/waterline-postgresql/dist/adapter.js:638:9


How do I resolve this issue?


FYI:


Waterline version: 0.12.1
Node version: v6.2.2
NPM version: 3.9.5
Operating system: Ubuntu 16.04 x64
waterline-postgresql: 0.14.8
async: 2.0.0-rc.4


And more details: https://github.com/balderdashy/waterline/issues/1376

Samuel Marks

unread,
Jul 8, 2016, 4:53:17 AM7/8/16
to sails.js
I've written a tiny test case showing this bug, only depends on waterline, waterline-postgresql, mocha, chai and async: https://github.com/balderdashy/waterline/issues/1376

Samuel Marks

unread,
Jul 8, 2016, 4:54:50 AM7/8/16
to sails.js


On Friday, July 8, 2016 at 2:59:45 PM UTC+10, Samuel Marks wrote:
Reply all
Reply to author
Forward
0 new messages