sgress454 / sails-hook-autoreload

Sails JS hook to autoreload controllers and models when changed.
231 stars 44 forks source link

Failed to reload ORM hook #60

Open nehalist opened 8 years ago

nehalist commented 8 years ago

error: Failed to reload ORM hook. Details: Error: Failed to reinitialize ORM because the initialize() method of the ORM hook returned an error. Details: Error: Consistency violation: Instantiated Waterline model already has a datastore property.

Packages:

    "bcryptjs": "^2.3.0",
    "ejs": "2.3.4",
    "grunt": "0.4.5",
    "grunt-contrib-clean": "0.6.0",
    "grunt-contrib-coffee": "0.13.0",
    "grunt-contrib-concat": "0.5.1",
    "grunt-contrib-copy": "0.5.0",
    "grunt-contrib-cssmin": "0.9.0",
    "grunt-contrib-jst": "0.6.0",
    "grunt-contrib-less": "1.1.0",
    "grunt-contrib-sass": "^1.0.0",
    "grunt-contrib-uglify": "0.7.0",
    "grunt-contrib-watch": "0.5.3",
    "grunt-sails-linker": "~0.10.1",
    "grunt-sync": "0.2.4",
    "include-all": "~0.1.6",
    "marlinspike": "^1.0.0",
    "passport": "^0.3.2",
    "passport-local": "^1.0.0",
    "rc": "1.0.1",
    "sails": "~0.12.3",
    "sails-auth": "^2.1.3",
    "sails-disk": "~0.10.9",
    "sails-hook-autoreload": "^0.13.1",
    "sails-permissions": "^2.2.0",
    "validator": "^5.2.0"

Sails version v0.12.3.

Guess it has something to do with sails permissions, sails auth or marlinspike (everything worked fine before they were installed).

pekpon commented 8 years ago

Same problem here. Any solution? Thanks!

sgress454 commented 8 years ago

@nehalist @pekpon Could one of of you create a repo that demonstrates the problem? I think that'd be the easiest way to see what's going on.

e.g.:

sails new sails-hook-autoreload-issue-60
cd sails-hook-autoreload-issue-60
npm install sails-hook-autoreload
# Now make whichever are the simplest/quickest changes which reproduce the issue,
# and when you for sure have the issue isolated, run:
git init
hub create  # or use the GitHub UI to create the repo and `git remote add` it manually
git add .
git commit -am 'Reproduces https://github.com/sgress454/sails-hook-autoreload/issues/60'
git push -u origin master
hub browse # or open the repo in your browser manually
# Then copy the URL of the new repo and paste it as a comment on this issue.
# We'll check it out, and since this way we'll be able to experience the problem
# ourselves, we should have no problem getting to the bottom of it.

Thanks man!

pekpon commented 8 years ago

@sgress454 thanks for your reply!

I finally make it work reinstalling sails-hook and sails-mongo

Thanks!

nehalist commented 8 years ago

@sgress454 here you go; https://github.com/nehalist/sails-hook-autoreload-issue-60

Fresh install. Problem seems to have nothing to do with sails-permissions, but with sails-auth. After installing sails-auth autoreload fails with the error mentioned in the entry post.

e/ Wrong mention, whoops...

sgress454 commented 8 years ago

Thanks @pekpon. It's very possible that these two hooks are just incompatible, but I will take a look.

RyanParsley commented 8 years ago

I do not have sails-auth or sails-permissions installed and I saw the same error. I had the swagger plugin that depended on marlinspike. Once I removed that plugin, my problems went away.

miraage commented 8 years ago

Problem still exists.

slavafomin commented 8 years ago

I have this problem also. Looks like this plugin makes development database extremely unstable, sometimes some rows are just dropped, sometimes the entire passport database table is dropped and it's all when migrate: safe config option is set. I'm removing this module for now.

giovannibenussi commented 8 years ago

Same problem

fourthdimension commented 8 years ago

Same here.

liratanak commented 8 years ago

I also got this error.

Failed to reload ORM hook.  Details: Error: Failed to reinitialize ORM because the `initialize()` method of the ORM hook returned an error.  
Details:
Error: Consistency violation: Instantiated Waterline model already has a `datastore` property.
...
fsin commented 8 years ago

Sehr geehrte Damen und Herren,

ich werde ab 07.09.2015 wieder im Büro sein, Ihre Nachricht wird nicht automatisch weitergeleitet. Ich werde Ihre Nachricht nach meiner Rückkehr beantworten.

Bitte kontaktieren Sie in dringenden Fällen Herrn Dr. Stefan Landshamer (sl@pharmit.de).

Mit freundlichen Grüßen, Florian Schindler

ghost commented 7 years ago

I had this problem when updating my orm hook connection name, after the model has already been setted up. Setting the new connection name in config/env/development.js , config/models.js and config/connection.js fixed that for me

clayrisser commented 7 years ago

I'm experiencing this same problem.

JonathanItakpe commented 7 years ago

create an autoreload.js file in you config folder with the following content: module.exports.autoreload = { active: true, overrideMigrateSetting: false, usePolling: false, dirs: [ "api/models", "api/controllers", "api/services", "config/locales" ], ignored: [ // Ignore all files with .ts extension "**.ts" ] };

Make sure you set migrate to safe in models.js

Fixed for me.

clayrisser commented 7 years ago

I did both of those things, and it didn't work.

antwal commented 7 years ago

Hi,

i have same problem when try edit config/locales/; i have tryed with autoreload.js and with watch.js but i receive always same error:

error: Failed to reload ORM hook. Details: Error: Failed to reinitialize ORM because the initialize() method of the ORM hook returned an error.
Details: Error: Consistency violation: Instantiated Waterline model already has a datastore property.

Thanks.

murbanowicz commented 7 years ago

The same issue here. Sails lifting up properly, but reload not working

inicio commented 7 years ago

Ditto. Same issue.

arjun-kava commented 7 years ago

same issue

sgress454 commented 7 years ago

Hi all, sorry for letting this one go for so long. While I see that this issue is affecting a number of people, just posting "same issue" isn't really helpful since the only repros I've seen so far involve the installation of other plugins that just might not be compatible with sails-hook-autoreload.

I try to make this clear in the README, but this tool is intended for rapid-prototyping of early-stage apps, where you're still building up your model schema and basic functionality, and don't want to have to keep lowering and re-lifting Sails every time you tweak a model or controller. Once your app reaches the level of sophistication where you've got other third-party hooks involved (especially ones that operate on models), there's no guarantees, and you're probably going to need a solution like forever which cold-boots your app every time a file is changed.

If someone can post a repo that shows this issue using just Sails and one of the core adapters (e.g. sails-postgresql or sails-mongo), and not involving another plugin, I'm happy to troubleshoot the issue!

HaiderMalik12 commented 7 years ago

Same issue here

HaiderMalik12 commented 7 years ago

I always get this error. error: A hook (orm) failed to load! error: Error (E_UNKNOWN) :: Encountered an unexpected error

murbanowicz commented 7 years ago

same here

2017-03-08 12:51 GMT+00:00 Haider notifications@github.com:

I always get this error. error: A hook (orm) failed to load! error: Error (E_UNKNOWN) :: Encountered an unexpected error

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sgress454/sails-hook-autoreload/issues/60#issuecomment-285032584, or mute the thread https://github.com/notifications/unsubscribe-auth/AI80kh0y20yxqGg1hSM8oa0WYUks1l5Zks5rjqRjgaJpZM4IDpK- .

HaiderMalik12 commented 7 years ago

Why sails team did you fix this issue ?

sgress454 commented 7 years ago

@HaiderMalik12 @murbanowicz please read my comment above, and provide an actual repo that reproduces the problem without having an incompatible package installed so we can troubleshoot. I've provided a sample list of incompatible packages in the README.

Fr33maan commented 7 years ago

I had this issue and successfully fixed it. It was about hooks in .sailsrc if my memory is good. I've got a repo which implements sails/sails-hook-autoreload/sails-webpack with react/redux, hot reloading, rebundling and so on. It's my starter pack for every sails project I have to do. The config is minimal, you all should find the way to correct this issue by checking your repo against mine.

The repo is called sails-webpack-react-2. The version 1 contains a similar error.

clayrisser commented 7 years ago

I just ended up using nodemod. It's super easy and requires no setup.

https://nodemon.io/

Fr33maan commented 7 years ago

Well, shutdown and restarting the server takes up to 3/4 seconds in my case (webpack because of React). The hook is better. I've got 2 watchers, one is sails-hook-autoreload which reload the sails app and the other is the webpack watcher wich rebundle my assets and reload the browser.

umeshp7 commented 5 years ago

Failed to reinitialize ORM because the initialize() method of the ORM hook returned an error. Details: userError: The attribute flow_screens on the flow_screens__screen_flows model is an association but also specifies a type property. This is not needed and will be automatically determined.

I am facing this issue. I haven't specified any type property for the association that I have created.