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

Issue with hot reload w/ moleculer-runner on node 14 #810

Closed
savearray2 opened this issue Sep 9, 2020 · 9 comments
Closed

Issue with hot reload w/ moleculer-runner on node 14 #810

savearray2 opened this issue Sep 9, 2020 · 9 comments

Comments

@savearray2
Copy link
Contributor

savearray2 commented Sep 9, 2020

When creating a docker image using FROM node:buster and running the following:

./node_modules/.bin/moleculer-runner --instances=$INSTANCE_CNT -H -c ./config.js --env services/**

I'm getting the following error:

[Runner] The feature watch recursively is unavailable on the current platform, which is being used to run Node.js TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
    at Object.watch (fs.js:1470:11)
    at /usr/src/cute/node_modules/moleculer/src/middlewares/hot-reload.js:281:19
    at Array.forEach (<anonymous>)
    at watchProjectFolders (/usr/src/cute/node_modules/moleculer/src/middlewares/hot-reload.js:276:13)
    at ServiceBroker.started (/usr/src/cute/node_modules/moleculer/src/middlewares/hot-reload.js:330:4)
    at /usr/src/cute/node_modules/moleculer/src/middleware.js:83:50
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  code: 'ERR_FEATURE_UNAVAILABLE_ON_PLATFORM'
}

The hot reload feature works properly when using the current version of node-lts (FROM node:lts-buster).

Version Used: Moleculer v0.14.10

Thank you :)

@intech
Copy link
Member

intech commented Sep 9, 2020

Problem code

watcher: fs.watch(folder, { recursive: true }, (eventType, filename) => {

Ref: nodejs/node#29947
Ref docs: https://nodejs.org/api/fs.html#fs_caveats

researched the problem, other projects started using the chokidar library to support cross-platform:

react-native-community/cli@6de4809

molant/cli@71f4a0a

@icebob
Copy link
Member

icebob commented Sep 9, 2020

Thanks @intech the investigation. My problem with chokidar that I want to minimalize the number of dependencies in the Moleculer core, so I don't like to add a new lib for hot-reload. Any native alternative solution?

@intech
Copy link
Member

intech commented Sep 9, 2020

@icebob I fully support your opinion on dependencies.

I have looked into several solutions and my vote for a respected developer https://github.com/mafintosh/recursive-watch

Examples:
https://github.com/gavoja/simple-watcher (maybe leaks)
https://github.com/gmasmejean/watch-recursivly (legacy, high risk leaks)
https://github.com/kbscript/watch-dog (legacy, not interesting)
other very old legacy or many dependencies...

@icebob
Copy link
Member

icebob commented Sep 9, 2020

Great, it looks very lightweight with one additional dependencies. Thanks, I will check it.

@Grandnainconnu
Copy link

Any update on this?

@savearray2
Copy link
Contributor Author

@icebob
Have you decided how to move forward with this?

Node v14 is now Active LTS, and v12 has been moved to Maintenance LTS status (as of 2020-11-30). I had to change my Dockerfile to specify FROM node:erbium-buster to keep using moleculer-runner in its current form.

I would be willing to make a pull request if you know which library you would like to use.

@icebob
Copy link
Member

icebob commented Dec 27, 2020

@savearray2 Thanks, I think we should try the recursive-watch.

@savearray2
Copy link
Contributor Author

@icebob
I've completed the initial pull request. Let me know if it's acceptable.
It's my first time contributing, though I use moleculer a lot.

@savearray2
Copy link
Contributor Author

Merged!

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

4 participants