event-catalog / eventcatalog

An open source documentation tool to bring discoverability to your event-driven architectures
https://eventcatalog.dev
MIT License
1.71k stars 145 forks source link

eventcatalog build fails with TS error if you have many objects #552

Closed otbe closed 2 months ago

otbe commented 3 months ago

Summary

When trying to build the catalog via eventcatalog build it fails with the following TS error:

src/components/DocsNavigation.astro:19:17 - error ts(2590): Expression produces a union type that is too complex to represent.

19 const allData = [ ...domains, ...services, ...messages, ...teams, ...users];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We work with 30 domains, 25 services and ~950 events. dev mode wokrs fine.

boyney123 commented 3 months ago

Hmmm interesting one, I'm going to create a big catalog locally for this.

Is it possible you could setup a fork of this big one at all? Saves me time building something massive, maybe ofc remove any PII information or sensitive info? Is that possible, or not? Let me know and I will have a look

otbe commented 3 months ago

I think this is not possible. Besides the events/services it also contains a lot of business process descriptions :)

otbe commented 2 months ago

I made some changes to be able to build it at least once locally see https://github.com/otbe/eventcatalog/tree/fix-ts-issues

However it turns out Im not able to finish the build. Node goes OOM even with NODE_OPTIONS=--max-old-space-size=25000 (in v1 --max-old-space-size=8192 was enough)

otbe commented 2 months ago

Ok little update. With 2.0.10 I get the following errors during build.

14:30:43 [check] Getting diagnostics for Astro files in .../eventcatalog/.eventcatalog-core...
src/components/DocsNavigation.astro:60:14 - error ts(7053): Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{ events: any; commands: any; domains: any; services: any; teams: any; users: any; }'.
60     visible: visibleCollections[item.collection],
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/components/DocsNavigation.astro:19:17 - error ts(2590): Expression produces a union type that is too complex to represent.

19 const allData = [ ...domains, ...services, ...messages, ...teams, ...users];
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/layouts/VisualiserLayout.astro:13:18 - error ts(2590): Expression produces a union type that is too complex to represent.

13 const navItems = [...domains, ...services, ...events, ...commands];

I tried to copy the the package.json/package-lock.json from a fresh new catalog generated by npx @eventcatalog/create-eventcatalog@latest my-catalog and it still fails. However I cannot reproduce it in the example catalog as long as I dont copy over my events/domains/services. With the changes in https://github.com/event-catalog/eventcatalog/compare/main...otbe:eventcatalog:fix-ts-issues Im able to build the catalog, or at least get over the type checking point. Still no luck with 25GB ram building the catalog. Im going to create a dedicated ticket for this.

otbe commented 2 months ago

Finding from today. The error starts to popup as soon as I add services. ~950 events and 30 domains are no issues. When I add the services (without any links to each other) it starts to fail with the errors from above.

otbe commented 2 months ago

I opened a merge request. No idea why there are so many unrelated changes after formatting via "format" script but the real changes are

Without these 3 lines I cannot build the big catalog. Might be some TS voodoo.