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

Hot reload circular dependency in monorepos #1220

Open
4 tasks done
ishfx opened this issue Jun 13, 2023 · 2 comments
Open
4 tasks done

Hot reload circular dependency in monorepos #1220

ishfx opened this issue Jun 13, 2023 · 2 comments
Labels
Status: Need reproduce Issue waits for reproducing

Comments

@ishfx
Copy link

ishfx commented Jun 13, 2023

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed
  • I'm reporting the issue to the correct repository

Current Behavior

In a monorepo, with 2 projects: a moleculer project and a helper project.
The moleculer project imports the helper project.
When the hot reload middleware is enabled, any file changes in the moleculer project causes high cpu usage because the hot relaod is stuck in circular dependency.

Expected Behavior

No circular dependency and normal hot reload.

Failure Information

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Create monorepo
  2. Create project B
  3. Create project A that imports moleculer and project B
  4. Launch project A with hot reload
  5. Change a file in project A and save.

Reproduce code snippet

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

  • Moleculer version: 0.14.29
  • NodeJS version: v16
  • Operating System: Linux

Solution

Add option to hot reload middleware to ignore build directory of other monorepo projects (dist, build, out, etc)

Here is the line : https://github.com/moleculerjs/moleculer/blob/v0.14.29/src/middlewares/hot-reload.js#L241

Example with hardcoded value :

if (fName.indexOf("node_modules") !== -1 || fName.indexOf("dist") !== -1) {
  if (cache.get(fName)) return;
  cache.set(fName, mod);
}
@ishfx ishfx changed the title Hot reload cycle dependency in monorepos Hot reload circular dependency in monorepos Jun 19, 2023
@icebob
Copy link
Member

icebob commented Jul 11, 2023

Please create a repro repo.

@icebob icebob added the Status: Need reproduce Issue waits for reproducing label Jul 11, 2023
@grinat
Copy link

grinat commented Aug 18, 2023

I have similar problem.

Time if ignore /dist disabled: ✔ ServiceBroker with 43 service(s) started successfully in 6s
Time if ignore /dist enabled: ✔ ServiceBroker with 43 service(s) started successfully in 3s

We need option like that: https://webpack.js.org/configuration/watch/#watchoptionsignored

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Need reproduce Issue waits for reproducing
Projects
None yet
Development

No branches or pull requests

3 participants