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

6.2.10+ crash when using workspaces and project references #630

Closed
lnewson opened this issue Jul 18, 2021 · 5 comments · Fixed by #642
Closed

6.2.10+ crash when using workspaces and project references #630

lnewson opened this issue Jul 18, 2021 · 5 comments · Fixed by #642

Comments

@lnewson
Copy link

lnewson commented Jul 18, 2021

Current behavior

When using version 6.2.10 or above and a workspace with project references, an exception is thrown and the plugin crashes:

/private/tmp/fork-ts-checker-bug/node_modules/typescript/lib/typescript.js:2479
            throw e;
            ^

Error: Debug Failure. False expression: /private/tmp/fork-ts-checker-bug/node_modules/my-b-project/lib/index.d.ts linked to nonexistent file /private/tmp/fork-ts-checker-bug/packages/b/lib/index.d.ts
    at realPath (/private/tmp/fork-ts-checker-bug/node_modules/typescript/lib/typescript.js:40897:18)
    at tryResolve (/private/tmp/fork-ts-checker-bug/node_modules/typescript/lib/typescript.js:40874:32)
    at /private/tmp/fork-ts-checker-bug/node_modules/typescript/lib/typescript.js:40857:69
    at Object.forEach (/private/tmp/fork-ts-checker-bug/node_modules/typescript/lib/typescript.js:384:30)
    at nodeModuleNameResolverWorker (/private/tmp/fork-ts-checker-bug/node_modules/typescript/lib/typescript.js:40857:25)
    at nodeModuleNameResolver (/private/tmp/fork-ts-checker-bug/node_modules/typescript/lib/typescript.js:40849:16)
    at Object.resolveModuleName (/private/tmp/fork-ts-checker-bug/node_modules/typescript/lib/typescript.js:40620:30)
    at loader_3 (/private/tmp/fork-ts-checker-bug/node_modules/typescript/lib/typescript.js:116478:99)
    at Object.loadWithLocalCache (/private/tmp/fork-ts-checker-bug/node_modules/typescript/lib/typescript.js:109259:42)
    at Object.compilerHost.resolveModuleNames (/private/tmp/fork-ts-checker-bug/node_modules/typescript/lib/typescript.js:116480:27)
RpcIpcMessagePortClosedError: Process 21927 exited with code "1" [null]
Issues checking service aborted - probably out of memory. Check the `memoryLimit` option in the ForkTsCheckerWebpackPlugin configuration.
If increasing the memory doesn't solve the issue, it's most probably a bug in the TypeScript or EsLint.
Error: No handler found for procedure closeReport.
Error: No handler found for procedure closeReport.
    at Object.<anonymous> (/private/tmp/fork-ts-checker-bug/node_modules/fork-ts-checker-webpack-plugin/lib/rpc/RpcService.js:21:27)
    at Generator.next (<anonymous>)
    at /private/tmp/fork-ts-checker-bug/node_modules/fork-ts-checker-webpack-plugin/lib/rpc/RpcService.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/private/tmp/fork-ts-checker-bug/node_modules/fork-ts-checker-webpack-plugin/lib/rpc/RpcService.js:4:12)
    at callListener (/private/tmp/fork-ts-checker-bug/node_modules/fork-ts-checker-webpack-plugin/lib/rpc/RpcService.js:16:39)
    at /private/tmp/fork-ts-checker-bug/node_modules/fork-ts-checker-webpack-plugin/lib/rpc/rpc-ipc/RpcIpcMessagePort.js:31:13
    at Set.forEach (<anonymous>)
    at process.handleMessage (/private/tmp/fork-ts-checker-bug/node_modules/fork-ts-checker-webpack-plugin/lib/rpc/rpc-ipc/RpcIpcMessagePort.js:30:26)
    at process.emit (node:events:365:28)

I did some investigation into this and the cause appears to be the memfs changes done in 6.2.10, as it appears to assume that after the initial run the files will always be written into the memory filesystem for every file/artifact in the bundle. However, this is not the case for project references, as it'll only rebuild the projects that have changed. This then means that files in unchanged projects/packages aren't in the memory based filesystem and it says they don't exist when calling fileExists. In addition to this, since the symlink isn't in the artifacts list, it uses the real filesystem which does resolve and is why it appears to think the symlink points to a non-existent file.

Current workarounds I'm aware of:

  • Set mode to write-references so the memory based filesystem is not used.
  • Use version 6.2.9 or lower.

Expected behavior

No error should occur, as the symlinked files exist in the real filesystem.

Steps to reproduce the issue

I've created a reproduction repo here and the steps are in the README: https://github.com/lnewson/fork-ts-checker-bug

Environment

  • fork-ts-checker-webpack-plugin: 6.2.10 or above (6.2.12)
  • typescript: 4.3.5 (latest)
  • eslint: N/A
  • webpack: 5.45.1 (latest)
  • os: macOS and Fedora
@lnewson lnewson added the bug label Jul 18, 2021
@phil-lgr
Copy link

phil-lgr commented Aug 5, 2021

Thank you! @lnewson, I can confirm that the issue is with the latest version 6.2.10 or v7 alpha, using 6.2.9 solved it for now

@piotr-oles
Copy link
Collaborator

Thanks for the report and investigation! 👍🏻 I will take a look soon :)

piotr-oles added a commit that referenced this issue Aug 7, 2021
In the situation, when there were already some files built in the real
fs, controlled typescript system returned true for fileExists call on
initial run and false on subsequent calls causing assertion in
TypeScript to fail.

✅ Closes: #630
piotr-oles added a commit that referenced this issue Aug 7, 2021
In the situation, when there were already some files built in the real
fs, controlled typescript system returned true for fileExists call on
initial run and false on subsequent calls causing assertion in
TypeScript to fail.

✅ Closes: #630
piotr-oles added a commit that referenced this issue Aug 8, 2021
In the situation, when there were already some files built in the real
fs, controlled typescript system returned true for fileExists call on
initial run and false on subsequent calls causing assertion in
TypeScript to fail.

✅ Closes: #630
@piotr-oles
Copy link
Collaborator

🎉 This issue has been resolved in version 6.3.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lnewson
Copy link
Author

lnewson commented Aug 8, 2021

Thanks @piotr-oles! 🏆

@piotr-oles
Copy link
Collaborator

🎉 This issue has been resolved in version 7.0.0-alpha.15 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

3 participants