sails-hook-autoreload
sails-hook-autoreload copied to clipboard
Autoreload failed. Got Error: Callback was already called
Every time Autoreload happens, Sails auto-migration will run but I got following error:
info: ·• Auto-migrating... (alter)
info: Hold tight, this could take a moment.
/Users/macOS/canvas/node_modules/parley/lib/private/Deferred.js:731
throw e.raw;
^
Error: Callback was already called.
at /Users/macOS/canvas/node_modules/async/dist/async.js:844:36
at /Users/macOS/canvas/node_modules/sails-hook-orm/lib/initialize.js:437:27
at /Users/macOS/canvas/node_modules/sails-hook-orm/lib/build-ontology-and-run-auto-migrations.js:133:25
at afterMigrate (/Users/macOS/canvas/node_modules/waterline-utils/lib/auto-migrations/private/run-alter-strategy/index.js:199:14)
at /Users/macOS/canvas/node_modules/async/dist/async.js:952:25
at iteratorCallback (/Users/macOS/canvas/node_modules/async/dist/async.js:995:17)
at /Users/macOS/canvas/node_modules/async/dist/async.js:847:20
at findCallback (/Users/macOS/canvas/node_modules/waterline-utils/lib/auto-migrations/private/run-alter-strategy/index.js:115:18)
at _tryToRunCb (/Users/macOS/canvas/node_modules/parley/lib/private/Deferred.js:518:20)
at /Users/macOS/canvas/node_modules/parley/lib/private/Deferred.js:694:16
at Deferred._.extend._WLModel [as _handleExec] (/Users/macOS/canvas/node_modules/waterline/lib/waterline/methods/find.js:214:20)
at Deferred.exec (/Users/macOS/canvas/node_modules/parley/lib/private/Deferred.js:644:10)
at simultaneouslyMigrateEachModel (/Users/macOS/canvas/node_modules/waterline-utils/lib/auto-migrations/private/run-alter-strategy/index.js:94:6)
at /Users/macOS/canvas/node_modules/async/dist/async.js:3047:20
at eachOfArrayLike (/Users/macOS/canvas/node_modules/async/dist/async.js:1002:13)
at eachOf (/Users/macOS/canvas/node_modules/async/dist/async.js:1052:9)
at Object.eachLimit (/Users/macOS/canvas/node_modules/async/dist/async.js:3111:7)
at runAlterStrategy (/Users/macOS/canvas/node_modules/waterline-utils/lib/auto-migrations/private/run-alter-strategy/index.js:39:9)
at Object.runAutoMigrations [as autoMigrations] (/Users/macOS/canvas/node_modules/waterline-utils/lib/auto-migrations/index.js:45:19)
at _afterInitializingWaterline (/Users/macOS/canvas/node_modules/sails-hook-orm/lib/build-ontology-and-run-auto-migrations.js:132:20)
at /Users/macOS/canvas/node_modules/waterline/lib/waterline.js:722:14
at /Users/macOS/canvas/node_modules/async/dist/async.js:952:25
at iteratorCallback (/Users/macOS/canvas/node_modules/async/dist/async.js:997:17)
at /Users/macOS/canvas/node_modules/async/dist/async.js:847:20
at /Users/macOS/canvas/node_modules/async/dist/async.js:952:25
at eachOfArrayLike (/Users/macOS/canvas/node_modules/async/dist/async.js:990:13)
at eachOf (/Users/macOS/canvas/node_modules/async/dist/async.js:1052:9)
at Object.eachLimit (/Users/macOS/canvas/node_modules/async/dist/async.js:3111:7)
What is "Sails auto-migration" ? Is it a package ?
Be aware that sails-hook-autoreload
is incompatible with a lot of packages.
Auto-migration here https://sailsjs.com/documentation/concepts/models-and-orm/model-settings
This should work without trouble. Please, provide a reproduction repo with minimal setup.
same issue here. I have a fresh new project, this is my package.json:
{
"name": "xxx",
"private": true,
"version": "0.0.0",
"description": "a Sails application",
"keywords": [],
"dependencies": {
"async": "2.0.1",
"connect-redis": "3.2.0",
"grunt": "1.0.1",
"lodash": "3.10.1",
"sails": "^1.0.0-40",
"sails-ember-rest": "^1.0.12",
"sails-hook-grunt": "^2.0.0",
"sails-hook-orm": "^2.0.0-16",
"sails-hook-sockets": "^1.4.0",
"sails-postgresql": "^1.0.0-12",
"socket.io-redis": "4.0.0"
},
"devDependencies": {
"eslint": "3.19.0",
"sails-hook-autoreload": "^1.1.0"
},
"scripts": {
"start": "NODE_ENV=production node app.js",
"test": "npm run lint && npm run custom-tests && echo 'Done.'",
"lint": "node ./node_modules/eslint/bin/eslint . --max-warnings=0 && echo '✔ Your code looks good.'",
"custom-tests": "echo \"(No other custom tests yet.)\" && echo",
"debug": "node debug app.js"
},
"main": "app.js"
}
@l1br3 here is a minimal example as you asked: https://github.com/gleam-ru/autoreload-issue
Steps to reproduce:
npm i
npm run dev
// edit ApiController
// save
// !!!CRAAASH!!!
Issue dissappears if you drop api/models/Model.js
file.
Thanks @gleam-ru I'm going to have a look. As I don't use sails 1.x for now I didn't dive into this earlier. If you succeed making a FIX, don't hesitate to PR or share it here.
Hello, I have updated my dependencies and now I have the same issue. After some search, I found that the "async" module have breaking changes in its v2.0.0, and it seems to match this issue :
"Calling a callback more than once is considered an error, and an error will be thrown. This had an explicit breaking change in waterfall. If you were relying on this behavior, you should more accurately represent your control flow as an event emitter or stream."
Same thing here, with a fresh Sails 1.0 generated project I uninstall sails-hook-autoreload until a fix is available :)
No update on this blocking issue since months, it seems this project is dead like Sails.js, sad...
Sorry I didn't take the time to solve it.
Le 1 mars 2018 15:04, "Zeex" [email protected] a écrit :
No update on this blocking issue since months, it seems this project is dead like Sails.js, sad...
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sgress454/sails-hook-autoreload/issues/84#issuecomment-369600982, or mute the thread https://github.com/notifications/unsubscribe-auth/ADUhqS_sJv-KylDTHflfGzjLaS9uvLAHks5tZ__ZgaJpZM4QdCEg .
+1
+1
+1
waiting...
I'm so busy dudes. I understand its blocking for you but money comes before open source and Im sure all of you understand that.
As we have the reproduction repo, maybe one of you who getting the error can make some research and try to fix the bug.
As soon as someone has a fix I can merge PR and ask repo owner to publish on npm.
Im really sorry and I really would like to magically solve this one as it seems to completely breack this package.
Le lun. 23 avr. 2018 à 00:00, l132a [email protected] a écrit :
waiting...
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sgress454/sails-hook-autoreload/issues/84#issuecomment-383396142, or mute the thread https://github.com/notifications/unsubscribe-auth/ADUhqQ6FdKL0BAPuMBslXTIrJk0ogr20ks5trLcigaJpZM4QdCEg .
+1
+1
+1
In './config/models.js' file I add ''
module.exports.models = { archiveModelIdentity: false }
https://sailsjs.com/documentation/reference/configuration/sails-config-models
It work for me!
@Wisperus thanks, nice workaround while waiting for a fix
Any update on a fix? Would be great to not disable archiveModel 🤔
temporary do,
archiveModelIdentity: false
in model config
The archiveModelIdentity: false
worked for me too! It would be great if this can be resolved anyway.
Did someone found a fix for this one ? The problem looks to be located in waterline so we need another way to reload ORM otherwise the callback is called more than once.
In './config/models.js' file I add ''
module.exports.models = { archiveModelIdentity: false }
https://sailsjs.com/documentation/reference/configuration/sails-config-models It work for me!
also worked for me using the actual sails 1.0 version.
Anyway, for those stumbling upon the same question o similar scenario of mine:
I wanted to use the sails
command (eg., sails console --drop
) along with the automatic reload, so I could test changes in waterline models right away after ctrl+save them.
You can use nodemon directly with the sails binary, using the normal argumments that you would pass to it. Personally, I drop this line under the package.json scripts section.
nodemon /usr/lib/node_modules/sails/bin/sails.js console --drop --redis
Hope somebody find this useful :shamrock:
I updated the readme to document that bug.
@l1br3 Thanks, for those arriving here for a solution will means a lot. :+1:
Does anyone know what the archiveModelIdentity
setting is for ?
Hi @l1br3 ,
The archiveModelIdentity
:
The identity of the model to use when calling .archive(). By default, this is the Archive model, an implicit model automatically defined by Sails/Waterline. Set to false to disable built-in support for soft-deletes.