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

CRA Typescript: Compiling forever, if node_modules getting changed, while webpack is running #5679

Closed
johannwagner opened this issue Nov 2, 2018 · 11 comments
Labels

Comments

@johannwagner
Copy link

johannwagner commented Nov 2, 2018

Is this a bug report?

Yes.

Did you try recovering your dependencies?

Yes.

Which terms did you search for in User Guide?

typescript, webpack, hangs

Environment

Whoops.

$ create-react-app --info

Environment Info:
(node:5138) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '1' of null
    at a.run.then.e (/usr/lib/node_modules/create-react-app/node_modules/envinfo/dist/envinfo.js:1:97255)
(node:5138) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:5138) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

  • Node 11
  • Create React App 2.1.0
  • npm 6.4.1

Steps to Reproduce

  1. Create a new CRA project with --typescript
  2. Link another npm package into this project.
  3. Updates files, which are included in the project, in the linked project

Expected Behavior

(Write what you thought would happen.)
Webpack should compile the new files.

Actual Behavior

Webpack hangs forever on Compiling.... If you terminate the process, it exits with exit code 0, but the compile process won't terminate and is stuck on 100% CPU forever.

Reproducible Demo

@johannwagner
Copy link
Author

johannwagner commented Nov 2, 2018

Maybe, it is a similar issue like #5667.

@miraage
Copy link

miraage commented Nov 2, 2018

I wonder, how is it possible to have node_modules directory being changed during the compilation.

@johannwagner
Copy link
Author

johannwagner commented Nov 2, 2018

@miraage

Example:
You develop in two projects. One project is your real application, built with CRA. The other application is a library. You build the library manually and linked them via npm link.

npm link creates a symbolic link from the real application node_modules folder to the library folder. This simulates an install without having a package for this. It is nice for developing and testing at the same time. In production, you won't use this.

So, if you build the lib manually, the node_modules folder changes and Webpack will start recompiling your application. At this point, not every single file is built, so there are ongoing changes in the directory, which is read by Webpack.

@miraage
Copy link

miraage commented Nov 2, 2018

First of all, this issue is not related to CRA. CRA is a tool to generate a modern React app. You have an issue with webpack, which is a different tool.

Then, it's totally expected to have a corrupted build in this case. Here is some documentation from the webpack website:
https://webpack.js.org/api/node/

The API only supports a single concurrent compilation at a time. When using run, wait for it to finish before calling run or watch again. When using watch, call close and wait for it to finish before calling run or watch again. Concurrent compilations will corrupt the output files.

You can try to open an issue in https://github.com/webpack/webpack repository, but I bet nobody wants to support similar cases.

So the eventual way for you: make a change -> compile -> see a change -> repeat

@johannwagner
Copy link
Author

Okay, I see your point.
I have other projects with the same stack, but without CRA, where the same case is working fine, so I was tempted to believe, that this is a CRA issue. I will report/ask this at webpack, thanks for your time.

Best,
Johann

@miraage
Copy link

miraage commented Nov 2, 2018

@johannwagner wow, it really worked for you? What webpack version did you use? Any chance you can setup a demo? If it is true, we must find the cause.

@Timer
Copy link
Contributor

Timer commented Nov 2, 2018

/cc @tabrindle see envinfo error please

@tabrindle
Copy link
Contributor

tabrindle commented Nov 2, 2018

Thanks @Timer - on it.

Update: I think this is a linux OS Version edge case where /etc/os-release is missing some info. It's actually already fixed in envinfo - I'll make a PR to update CRA to envinfo@5.11.1

@tabrindle
Copy link
Contributor

@johannwagner feel free to run npx envinfo@latest --preset create-react-app and paste its contents here, the issue preventing --info from working should be resolved.

@stale
Copy link

stale bot commented Dec 29, 2018

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Dec 29, 2018
@stale
Copy link

stale bot commented Jan 6, 2019

This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.

@stale stale bot closed this as completed Jan 6, 2019
@lock lock bot locked and limited conversation to collaborators Jan 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants