You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sails version: 0.12.7 Node version: 6.7.0 NPM version: 3.10.8 Operating system: Mac OSX El Capitan
To override a core hook, you can create a new module and name it similarly as the core hook but under a different scope (for example, @ioredis/sails-hook-sockets) and with the sails.isHook = true in the package.json.
In the moduleLoader hooks library of Sails, the nodeModulesFolder function goes through the node_modules folder in order to search for hooks to load, with a max depth of 3.
The issue is that with npm v3, the node_module folder is flattened, so the max depth does not apply. For example, since sails requires the sails-hook-sockets module, instead of being under node_modules/sails/node_modules/sails-hook-sockets, it's now directly under /node_modules/sails-hook-sockets.
What it means is that if your custom hook has a sort order inferior (alphabetically I guess) in regards to the core hook, the custom hook will get loaded first and then overwritten by the core hook.
Make sure you have nothing under the node_modules folder (rm -rf node_modules) and do a npm install
Lift your sail application with the verbose log level to see all the user-related hooks logging information
You will see the following logs:
What's happening here: sails finds my custom hook (under node_modules/@bsft/sails-hook-sockets) but then finds the core hook (under node_modules/sails-hook-sockets), so it loads that one instead.
The same issue probably applies to the ORM hook since it's also required as a dependency and not part of the sails core libraries.
I will try to contribute through a PR to fix this issue.
Alright, this is patched on master -- the hook loader will ignore the default installed hooks (sails-hook-sockets, sails-hook-orm and sails-hook-helpers) so that they can be safely overridden. The workaround should get you going on v0.12 until then. Thanks for posting @Albi34!
Sails version: 0.12.7
Node version: 6.7.0
NPM version: 3.10.8
Operating system: Mac OSX El Capitan
To override a core hook, you can create a new module and name it similarly as the core hook but under a different scope (for example, @ioredis/sails-hook-sockets) and with the sails.isHook = true in the package.json.
In the moduleLoader hooks library of Sails, the nodeModulesFolder function goes through the node_modules folder in order to search for hooks to load, with a max depth of 3.
The issue is that with npm v3, the node_module folder is flattened, so the max depth does not apply. For example, since sails requires the sails-hook-sockets module, instead of being under node_modules/sails/node_modules/sails-hook-sockets, it's now directly under /node_modules/sails-hook-sockets.
What it means is that if your custom hook has a sort order inferior (alphabetically I guess) in regards to the core hook, the custom hook will get loaded first and then overwritten by the core hook.
To reproduce you can follow these steps:
You will see the following logs:
What's happening here: sails finds my custom hook (under node_modules/@bsft/sails-hook-sockets) but then finds the core hook (under node_modules/sails-hook-sockets), so it loads that one instead.
The same issue probably applies to the ORM hook since it's also required as a dependency and not part of the sails core libraries.
I will try to contribute through a PR to fix this issue.
I created a repository here that you can use to quickly reproduce the issue: https://github.com/albi34/sails-issue-hooks
The text was updated successfully, but these errors were encountered: