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

Autoreload failed. Got Error: Callback was already called #84

Open
NguyenAnX opened this issue Nov 14, 2017 · 29 comments
Open

Autoreload failed. Got Error: Callback was already called #84

NguyenAnX opened this issue Nov 14, 2017 · 29 comments

Comments

@NguyenAnX
Copy link

NguyenAnX commented Nov 14, 2017

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)
@Fr33maan
Copy link
Collaborator

What is "Sails auto-migration" ? Is it a package ?
Be aware that sails-hook-autoreload is incompatible with a lot of packages.

@NguyenAnX
Copy link
Author

@Fr33maan
Copy link
Collaborator

This should work without trouble. Please, provide a reproduction repo with minimal setup.

@erzzo
Copy link

erzzo commented Nov 21, 2017

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"
}

@gleam-ru
Copy link

gleam-ru commented Dec 7, 2017

@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.

@Fr33maan
Copy link
Collaborator

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.

@magiksd
Copy link

magiksd commented Dec 19, 2017

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."

@Tinostarn
Copy link

Same thing here, with a fresh Sails 1.0 generated project
I uninstall sails-hook-autoreload until a fix is available :)

@magiksd
Copy link

magiksd commented Mar 1, 2018

No update on this blocking issue since months, it seems this project is dead like Sails.js, sad...

@Fr33maan
Copy link
Collaborator

Fr33maan commented Mar 1, 2018 via email

@lvsjack
Copy link

lvsjack commented Apr 9, 2018

+1

2 similar comments
@oesile
Copy link

oesile commented Apr 17, 2018

+1

@rock1246
Copy link

+1

@l132a
Copy link

l132a commented Apr 22, 2018

waiting...

@Fr33maan
Copy link
Collaborator

Fr33maan commented Apr 22, 2018 via email

@Jakevin
Copy link

Jakevin commented Apr 25, 2018

+1

2 similar comments
@foobic
Copy link

foobic commented Apr 28, 2018

+1

@nino-vrijman
Copy link

+1

@Wisperus
Copy link

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!

@magiksd
Copy link

magiksd commented May 30, 2018

@Wisperus thanks, nice workaround while waiting for a fix

@vpiskunov
Copy link

Any update on a fix? Would be great to not disable archiveModel 🤔

@sadi304
Copy link

sadi304 commented Jul 20, 2018

temporary do,

archiveModelIdentity: false

in model config

@fsinisi90
Copy link

The archiveModelIdentity: false worked for me too! It would be great if this can be resolved anyway.

@Fr33maan
Copy link
Collaborator

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.

@codeinearts
Copy link

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 ☘️

@Fr33maan
Copy link
Collaborator

I updated the readme to document that bug.

@codeinearts
Copy link

@L1br3
Thanks, for those arriving here for a solution will means a lot. 👍

@Fr33maan
Copy link
Collaborator

Fr33maan commented Jan 1, 2019

Does anyone know what the archiveModelIdentity setting is for ?

@andyngdz
Copy link

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.

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

No branches or pull requests