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

projectReferences: true causes node to not exit (webpack host) #998

Closed
sublimator opened this issue Sep 11, 2019 · 13 comments · Fixed by #1003
Closed

projectReferences: true causes node to not exit (webpack host) #998

sublimator opened this issue Sep 11, 2019 · 13 comments · Fixed by #1003

Comments

@sublimator
Copy link

sublimator commented Sep 11, 2019

Expected Behaviour

Node to exit once webpack finished

Actual Behaviour

Node just hangs and doesn't exit.
Have tried node 10 and 12.
Both hang

Steps to Reproduce the Problem

  1. clone this repository
  2. yarn install
  3. yarn build.
  4. cd test/execution-tests/3.6.0_projectReferencesToBeBuilt
  5. yarn install
  6. ../../../node_modules/.bin/webpack-cli --config webpack.config.js

image

Location of a Minimal Repository that Demonstrates the Issue.

This repo

@sublimator
Copy link
Author

sublimator commented Sep 11, 2019

Referring to:
#935 (comment)

@sublimator
Copy link
Author

sublimator commented Sep 11, 2019

Using this commit:

commit bfa48c75adc424a33bbc1f0ec3eeddb8ea1c2722 (HEAD -> master, tag: v6.1.0, origin/master, origin/HEAD)
Merge: ab3ba29 a47f244
Author: Andrew Branch <andrewbranch@users.noreply.github.com>
Date:   Tue Sep 10 14:38:23 2019 -0700

    Merge pull request #935 from sheetalkamat/solutionBuilder
    
    Using Solution builder to build project references

@sublimator
Copy link
Author

sublimator commented Sep 11, 2019

Running the webpack command with node --inspect and running process._getActiveHandles() one can see that there are some typescript.js:5055 StatWatcher things open ...

image

@sublimator
Copy link
Author

sublimator commented Sep 11, 2019

image

Seems like due to above in instances.ts ^^^

Need to pick up kid from school, will investigate further later, but it doesn't seem like it's honoring the webpack --watch mode ...

Not very familiar with other contexts/use cases for ts-loader ...

@sublimator
Copy link
Author

sublimator commented Sep 11, 2019

Ok, so it seems the code is using the compiler.createSolution*Watchapis ...
See here for a quick hack that gets it to exit cleanly:
sublimator@095e046

Not sure how you guys want to solve this or why watch apis were chosen?

@sublimator
Copy link
Author

sublimator commented Sep 11, 2019

@sheetalkamat
Any ideas ?

@johnnyreilly
Copy link
Member

johnnyreilly commented Sep 11, 2019

cc @andrewbranch

@sheetalkamat
Copy link
Contributor

sheetalkamat commented Sep 11, 2019

I think microsoft/TypeScript#33145 should fix that. try using typescript@next to see if the problem resolves?

Btw I tried the repro steps and it doesn't seem to repro

c:\temp\ts-loader\test\execution-tests\3.6.0_projectReferencesToBeBuilt>..\..\..\node_modules\.bin\webpack-cli --config webpack.config.js
Hash: 4a1768846452d2ef20f0
Version: webpack 4.20.2
Time: 78ms
Built at: 09/11/2019 11:09:50 AM
    Asset      Size  Chunks             Chunk Names
bundle.js  6.47 KiB    main  [emitted]  main
Entrypoint main = bundle.js
[./src/app.ts] 2.49 KiB {main} [built] [failed] [1 error]

ERROR in ./src/app.ts
Module build failed (from c:/temp/ts-loader/index.js):
Error: Cannot find module './dist'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
    at Function.Module._load (internal/modules/cjs/loader.js:508:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (c:\temp\ts-loader\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
    at Object.<anonymous> (c:\temp\ts-loader\index.js:1:76)
    at Module._compile (c:\temp\ts-loader\node_modules\v8-compile-cache\v8-compile-cache.js:178:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (c:\temp\ts-loader\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
    at loadLoader (c:\temp\ts-loader\node_modules\loader-runner\lib\loadLoader.js:13:17)
    at iteratePitchingLoaders (c:\temp\ts-loader\node_modules\loader-runner\lib\LoaderRunner.js:169:2)
    at runLoaders (c:\temp\ts-loader\node_modules\loader-runner\lib\LoaderRunner.js:362:2)
    at NormalModule.doBuild (c:\temp\ts-loader\node_modules\webpack\lib\NormalModule.js:265:3)
    at NormalModule.build (c:\temp\ts-loader\node_modules\webpack\lib\NormalModule.js:412:15)
    at Compilation.buildModule (c:\temp\ts-loader\node_modules\webpack\lib\Compilation.js:618:10)
    at moduleFactory.create (c:\temp\ts-loader\node_modules\webpack\lib\Compilation.js:996:12)
    at factory (c:\temp\ts-loader\node_modules\webpack\lib\NormalModuleFactory.js:405:6)
    at hooks.afterResolve.callAsync (c:\temp\ts-loader\node_modules\webpack\lib\NormalModuleFactory.js:155:13)
    at AsyncSeriesWaterfallHook.eval [as callAsync] (eval at create (c:\temp\ts-loader\node_modules\webpack\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:6:1)
    at AsyncSeriesWaterfallHook.lazyCompileHook (c:\temp\ts-loader\node_modules\webpack\node_modules\tapable\lib\Hook.js:154:20)
    at resolver (c:\temp\ts-loader\node_modules\webpack\lib\NormalModuleFactory.js:138:29)
    at process.nextTick (c:\temp\ts-loader\node_modules\webpack\lib\NormalModuleFactory.js:342:9)
    at process._tickCallback (internal/process/next_tick.js:61:11)

@sublimator
Copy link
Author

sublimator commented Sep 11, 2019

Oh, right, must “yarn build” first?

@sublimator
Copy link
Author

sublimator commented Sep 11, 2019

Will try “next” when back home, thank :)

@sublimator
Copy link
Author

sublimator commented Sep 12, 2019

@sheetalkamat

I tried typescript@next (typescript@3.7.0-dev.20190912)and had no luck. The stall is still there.
I updated the repro steps to include the missing yarn build step so you shouldn't get Cannot find module './dist'.

Why using createSolutionBuilderWithWatch api vs createSolutionBuilder ?
Is there any way to stop the watches if using the former ?
The watch handles are what is keeping the process alive I am fairly sure

see: #998 (comment)

edit: it seems someone was able to repro on a windows 10 machine
#935 (comment)

@sublimator sublimator changed the title projectReferences: true causes node to not exit projectReferences: true causes node to not exit (webpack host) Sep 13, 2019
@sheetalkamat
Copy link
Contributor

sheetalkamat commented Sep 13, 2019

@sublimator you are right.. I didn't realize that I forgot to do something with watch similar to what we do with the WatchHost, I believe we need watch functionality for --watch scenarios.
I remembered that this was todo.. While in normal build scenario non watch makes sense but we would want to handle --watch portion of it since webpack wont know about the referenced project's files (to watch).

@sublimator
Copy link
Author

sublimator commented Sep 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants