Current behavior
Sometimes when saving files quickly after another and possibly when many file watchers are active the ApiIncrementalChecker is outputing the previous Diagnostics.
Expected behavior
Always use new diagnostics
Steps to reproduce the issue
Change and save files with and without errors repeatedly causes it to randomly not displaying the error but old diagnostics.
Possible solution
This might be a windows/os issue cause it's related to file watchers.
The reason is that webpack triggers a compile but the filewatcher of the CompilerHost didn't receive that change yet. Therefor the callback of the watched file is not triggered and no compilation happens. There is an if statement saying that if no compilation happened it's assumed to not be a related file to typescript therefore old diagnostics apply.
Possible solutions I can think of: Wait for a set time of ms until at least one change event happend (needs a timeout as unrelated files might have changed).
For tests I made a while loop around
|
this.fileWatchers.forEach(item => { |
|
for (const e of item.events) { |
|
item.callback(e.fileName, e.eventKind); |
|
files.push(e.fileName); |
|
if ( |
|
e.eventKind === this.typescript.FileWatcherEventKind.Created || |
|
e.eventKind === this.typescript.FileWatcherEventKind.Changed |
|
) { |
|
updatedFiles.push(e.fileName); |
|
} else if ( |
|
e.eventKind === this.typescript.FileWatcherEventKind.Deleted |
|
) { |
|
removedFiles.push(e.fileName); |
|
} |
|
} |
|
item.events.length = 0; |
|
}); |
until at least one "item.callback" is triggered or 100ms are over. That fixed the problem but I feel like it's not a good solution.
A better approach I can think of is passing the changed files from webpack to that fileWatchers list and call the "callback" as long as the filepath matches, but I'm not familiar with webpack plugins and it might be a bit hard to pass that data down to the service.
Environment
- fork-ts-checker-webpack-plugin: master
- typescript: ^3.0.1
- tslint: ^5.11.0
- webpack: ^5.0.0-alpha.5
- os: Windows 10
Current behavior
Sometimes when saving files quickly after another and possibly when many file watchers are active the ApiIncrementalChecker is outputing the previous Diagnostics.
Expected behavior
Always use new diagnostics
Steps to reproduce the issue
Change and save files with and without errors repeatedly causes it to randomly not displaying the error but old diagnostics.
Possible solution
This might be a windows/os issue cause it's related to file watchers.
The reason is that webpack triggers a compile but the filewatcher of the CompilerHost didn't receive that change yet. Therefor the callback of the watched file is not triggered and no compilation happens. There is an if statement saying that if no compilation happened it's assumed to not be a related file to typescript therefore old diagnostics apply.
Possible solutions I can think of: Wait for a set time of ms until at least one change event happend (needs a timeout as unrelated files might have changed).
For tests I made a while loop around
fork-ts-checker-webpack-plugin/src/CompilerHost.ts
Lines 193 to 209 in 04581f4
until at least one "item.callback" is triggered or 100ms are over. That fixed the problem but I feel like it's not a good solution.
A better approach I can think of is passing the changed files from webpack to that fileWatchers list and call the "callback" as long as the filepath matches, but I'm not familiar with webpack plugins and it might be a bit hard to pass that data down to the service.
Environment