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

Typescript 4.4 leaks watchers #45633

Closed
RichyHBM opened this issue Aug 30, 2021 · 1 comment
Closed

Typescript 4.4 leaks watchers #45633

RichyHBM opened this issue Aug 30, 2021 · 1 comment
Assignees

Comments

@RichyHBM
Copy link

@RichyHBM RichyHBM commented Aug 30, 2021

Bug Report

🔎 Search Terms

  • leak
  • watcher

🕗 Version & Regression Information

4.4

  • This changed between versions 4.3.5 and 4.4.2
  • This is still the behavior in next version 4.5.0-dev.20210830

Playground Link

https://github.com/sveltejs/template

🙁 Actual behavior

Builds hang indefinitely

🙂 Expected behavior

Build should complete within a timely manner.


This is a bug to relay the information @michael42 found in the rollup bug rollup/plugins#983

Running my (hanging) build (with an empty file to bundle) using why-is-node-running produces this output:

There are 13 handle(s) keeping the process running

# Timeout
node:internal/async_hooks:205                                                                    
node:internal/async_hooks:495                                                                    
node:internal/timers:162                                                                         
node:internal/timers:196                                                                         
/project/rollup.config.js:16                                   - dir: "build",
node:internal/modules/cjs/loader:1101                                                            
/project/node_modules/rollup/dist/shared/loadConfigFile.js:540 - module._compile(bundledCode, requiredFileName);
node:internal/modules/cjs/loader:981                                                             

# TTYWRAP
node:internal/async_hooks:205                                                       
node:internal/bootstrap/switches/is_main_thread:47                                  
node:internal/bootstrap/switches/is_main_thread:135                                 
node:internal/console/constructor:216                                               
node:internal/console/constructor:333                                               
node:internal/console/constructor:368                                               
/project/node_modules/rollup/dist/bin/rollup:1506 - loadConfigFile_js.stderr(loadConfigFile_js.cyan(`\n${loadConfigFile_js.bold(inputFiles)} → ${loadConfigFile_js.bold(files.join(', '))}...`));
/project/node_modules/rollup/dist/bin/rollup:1692 - await build(inputOptions, warnings, command.silent);

# STATWATCHER
node:internal/async_hooks:205                                                               
node:internal/fs/watchers:105                                                               
/project/node_modules/typescript/lib/typescript.js:7670   - _fs.watchFile(fileName, { persistent: true, interval: pollingInterval }, fileChanged);
/project/node_modules/typescript/lib/typescript.js:6924   - watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval, options),
/project/node_modules/typescript/lib/typescript.js:7247   - return pollingWatchFile(fileName, callback, PollingInterval.Low, /*options*/ undefined);
/project/node_modules/typescript/lib/typescript.js:110912 - watchFile: function (file, callback, pollingInterval, options) { return host.watchFile(file, callback, pollingInterval, options); },
/project/node_modules/typescript/lib/typescript.js:110938 - factory[key].call(/*thisArgs*/ undefined, file, cb, flags, options, detailInfo1, detailInfo2) :
/project/node_modules/typescript/lib/typescript.js:118559 - return watchFile(file, function (fileName, eventKind) { return callback(fileName, eventKind, path); }, pollingInterval, options, watchType);

# STATWATCHER
node:internal/async_hooks:205                                                               
node:internal/fs/watchers:105                                                               
/project/node_modules/typescript/lib/typescript.js:7670   - _fs.watchFile(fileName, { persistent: true, interval: pollingInterval }, fileChanged);
/project/node_modules/typescript/lib/typescript.js:6924   - watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval, options),
/project/node_modules/typescript/lib/typescript.js:7247   - return pollingWatchFile(fileName, callback, PollingInterval.Low, /*options*/ undefined);
/project/node_modules/typescript/lib/typescript.js:110912 - watchFile: function (file, callback, pollingInterval, options) { return host.watchFile(file, callback, pollingInterval, options); },
/project/node_modules/typescript/lib/typescript.js:110938 - factory[key].call(/*thisArgs*/ undefined, file, cb, flags, options, detailInfo1, detailInfo2) :
/project/node_modules/typescript/lib/typescript.js:118559 - return watchFile(file, function (fileName, eventKind) { return callback(fileName, eventKind, path); }, pollingInterval, options, watchType);

[... 9 more # STATWATCHER] 

It seems to me that TypeScript is keeping open a few watchers... I added a few console.log at typescript.js:7670 and it seems that Typescript creates a lot of watchers and does not unregister all of them (383/394 in my case, which is consistent with the 11 STATWATCHER in the output). Analyzing the output, it seems that the watchers for the package.jsons of the @types packages are not properly closed (package.jsons are only loaded from @types packages in my output and all 11 of them are not closed):

Set(11) {
  '/project/common/node_modules/@types/pouchdb-core/package.json',
  '/project/common/node_modules/@types/pouchdb-find/package.json',
  '/project/node_modules/@types/pouchdb-core/package.json',
  '/project/node_modules/@types/pouchdb-find/package.json',
  '/project/server/node_modules/@types/benchmark/package.json',
  '/project/server/node_modules/@types/debug/package.json',
  '/project/server/node_modules/@types/express-serve-static-core/package.json',
  '/project/server/node_modules/@types/node/package.json',
  '/project/server/node_modules/@types/pouchdb-core/package.json',
  '/project/server/node_modules/@types/pouchdb-find/package.json',
  '/project/server/node_modules/@types/serve-static/package.json',
}
@andrewbranch
Copy link
Member

@andrewbranch andrewbranch commented Aug 30, 2021

Possibly related to #44935

Loading

@andrewbranch andrewbranch added this to the TypeScript 4.4.3 milestone Aug 30, 2021
zackschuster added a commit to eleith/emailjs that referenced this issue Sep 3, 2021
typescript update blocked due to microsoft/TypeScript#45633
zackschuster added a commit to eleith/emailjs that referenced this issue Sep 3, 2021
typescript update blocked due to microsoft/TypeScript#45633
Lodin added a commit to Lodin/construct-style-sheets that referenced this issue Sep 4, 2021
denolehov added a commit to denolehov/obsidian-git that referenced this issue Sep 5, 2021
FlorianWendelborn added a commit to 3YOURMIND/kotti that referenced this issue Sep 7, 2021
TS 4.4.2 is unfortunately not possible yet, as there’s this rollup+typescript bug that will most likely be fixed in TS 4.4.3:

rollup/plugins#983
microsoft/TypeScript#45633
HansAuger added a commit to 3YOURMIND/kotti that referenced this issue Sep 12, 2021
TS 4.4.2 is unfortunately not possible yet, as there’s this rollup+typescript bug that will most likely be fixed in TS 4.4.3:

rollup/plugins#983
microsoft/TypeScript#45633
FlorianWendelborn added a commit to 3YOURMIND/kotti that referenced this issue Sep 14, 2021
TS 4.4.2 is unfortunately not possible yet, as there’s this rollup+typescript bug that will most likely be fixed in TS 4.4.3:

rollup/plugins#983
microsoft/TypeScript#45633
FlorianWendelborn added a commit to 3YOURMIND/kotti that referenced this issue Sep 15, 2021
TS 4.4.2 is unfortunately not possible yet, as there’s this rollup+typescript bug that will most likely be fixed in TS 4.4.3:

rollup/plugins#983
microsoft/TypeScript#45633
FlorianWendelborn added a commit to 3YOURMIND/kotti that referenced this issue Sep 15, 2021
TS 4.4.2 is unfortunately not possible yet, as there’s this rollup+typescript bug that will most likely be fixed in TS 4.4.3:

rollup/plugins#983
microsoft/TypeScript#45633
github-actions bot pushed a commit to 3YOURMIND/kotti that referenced this issue Sep 15, 2021
TS 4.4.2 is unfortunately not possible yet, as there’s this rollup+typescript bug that will most likely be fixed in TS 4.4.3:

rollup/plugins#983
microsoft/TypeScript#45633
FlorianWendelborn added a commit to 3YOURMIND/kotti that referenced this issue Sep 15, 2021
TS 4.4.2 is unfortunately not possible yet, as there’s this rollup+typescript bug that will most likely be fixed in TS 4.4.3:

rollup/plugins#983
microsoft/TypeScript#45633
FlorianWendelborn added a commit to 3YOURMIND/kotti that referenced this issue Sep 16, 2021
TS 4.4.2 is unfortunately not possible yet, as there’s this rollup+typescript bug that will most likely be fixed in TS 4.4.3:

rollup/plugins#983
microsoft/TypeScript#45633
FlorianWendelborn added a commit to 3YOURMIND/kotti that referenced this issue Sep 16, 2021
TS 4.4.2 is unfortunately not possible yet, as there’s this rollup+typescript bug that will most likely be fixed in TS 4.4.3:

rollup/plugins#983
microsoft/TypeScript#45633
FlorianWendelborn added a commit to 3YOURMIND/kotti that referenced this issue Sep 16, 2021
TS 4.4.2 is unfortunately not possible yet, as there’s this rollup+typescript bug that will most likely be fixed in TS 4.4.3:

rollup/plugins#983
microsoft/TypeScript#45633
FlorianWendelborn added a commit to 3YOURMIND/kotti that referenced this issue Sep 16, 2021
TS 4.4.2 is unfortunately not possible yet, as there’s this rollup+typescript bug that will most likely be fixed in TS 4.4.3:

rollup/plugins#983
microsoft/TypeScript#45633
FlorianWendelborn added a commit to 3YOURMIND/kotti that referenced this issue Sep 21, 2021
TS 4.4.2 is unfortunately not possible yet, as there’s this rollup+typescript bug that will most likely be fixed in TS 4.4.3:

rollup/plugins#983
microsoft/TypeScript#45633

Co-Authored-By: Moritz Vetter <16950410+HansAuger@users.noreply.github.com>
FlorianWendelborn added a commit to 3YOURMIND/kotti that referenced this issue Sep 21, 2021
TS 4.4.2 is unfortunately not possible yet, as there’s this rollup+typescript bug that will most likely be fixed in TS 4.4.3:

rollup/plugins#983
microsoft/TypeScript#45633

Co-Authored-By: Moritz Vetter <16950410+HansAuger@users.noreply.github.com>
carsoli added a commit to 3YOURMIND/kotti that referenced this issue Sep 22, 2021
TS 4.4.2 is unfortunately not possible yet, as there’s this rollup+typescript bug that will most likely be fixed in TS 4.4.3:

rollup/plugins#983
microsoft/TypeScript#45633

Co-Authored-By: Moritz Vetter <16950410+HansAuger@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants