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
break circular references by splitting some files into two #747
Conversation
Hi @leemhenson
Did you check for multiple versions of
I would recommend to also file an issue in the TypeScript repo.
Not sure I'm following, does the linked repo contain a repro? |
It is pinned to the same exact version (1.14.2) in both repos, and I checked with
If I could put together a repro I would. 😬
Eh, no. I was just showing how our project is roughly structured (e.g. the nesting). Sadly I can't make it fail with this small repo size. |
Any thoughts about what to do with this issue? There is lots of anecdotal evidence that circular dependencies cause a variety of unexpected silent or not-so-silent issues. Typescript's issue tracker has lots of hits, including this one added in just the last week: microsoft/TypeScript#29997 |
@leemhenson I'm sorry but we can't do much without a repro |
93de5eb
to
6f0676d
Compare
The times when I've encountered these sorts of issues were due to having a library like However, this is a workaround. The more ideal solution would be for fp-ts ecosystem libraries to require these libraries as peer dependencies with looser version requirements instead of directly depending on them. This would (hopefully) allow users to avoid accidentally having more than one version of the same library installed at the same time and running into problems due to there being multiple versions of the same types. |
Having done some more digging, I am leaning towards this being the same issue as: The nested node_modules is the common trigger, I believe. I have modified my Digging further, I was wondering if the multi-version crash we know about is maybe due to the import { URI2HKT2 } from "fp-ts/lib/HKTv14_1"; It does not believe that to be an error, despite the version of fp-ts installed locally not having an I can't imagine this is intended module resolution behaviour for TS, so I'll open an issue over there. |
I've opened this issue: microsoft/TypeScript#30124 I'm going to close this one with the expectation that something will come out of that or the other related issues. |
@gcanti I managed to put together a simple repro of oom crash with fp-ts: https://github.com/leemhenson/project-refs-oom-repro Raised as an issue on TypeScript here: |
Thanks @leemhenson |
Hi
I've been encountering an issue which occurs when using fp-ts on a large codebase, where one package using fp-ts imports from another package also using fp-ts. The sympton is that
tsc
crashes with an out of memory error. It is definitely linked to fp-ts, as compiling the project without fp-ts does not crash. I believe it is due to the circular references that exist in the codebase. Sadly the issue is not reproducible using a small repo (https://github.com/leemhenson/fp-ts-oom-repro), it only manifests when the codebase is large enough. My guess is that the size of the codebase tripstsc
into some other mode.To fix it, I have branched off 1.14.2 and:
Option.ts
andOption_.ts
. The underscore version contains the "meat" of the type without imports that cause the circular references, while the non-underscored version has those imports and the functions that use them, and also re-exports from the non-underscored file. This helps to preserve the same interface to anyone currently importing from, say,Option.ts
.Using a git reference in the package.json to a compiled version of my branch seems to resolve the issue.
I fully expect you will have preferences in how you would like to structure the code rather than the underscore approach I've used, this is just a proof of concept that shows it is possible to break the cycles.