trumbitta / nx-trumbitta

💡An attempt to start collecting all of my Nx-related Open Source work in a mono-repo.
MIT License
47 stars 11 forks source link

api generation hangs #70

Closed iceteabottle closed 2 years ago

iceteabottle commented 2 years ago

I have a problem with the api generation within a quite huge nx workspace:

$ npx nx run my-api:generate-sources

> nx run my-api:generate-sources

Deleting outputDir libs/my-api/src...
Done deleting outputDir libs/my-api/src.

And that's it. No more output, the command hangs... I have multiple apis to generate and now the second api has the same problem.

My workaround is to use the openapi-generator-cli without this nx plugin. This is also the "proof" that the problem seems to be in this pugin...

Sadly I cannot share my api spec file since it's closed source.

Any idea? Honestly I have no idea to debug it.

trumbitta commented 2 years ago

Hey, can you share a public repo reproducing the issue so I can have a look at it?

One of the most common reasons for this kind of problem is some misconfiguration leading to the plugin not finding the spec file.

See also https://github.com/trumbitta/nx-trumbitta/issues/44

iceteabottle commented 2 years ago

Thanks for your response. Sadly no. It's all closed source 🙈 I guess it's not possible to easy reproduce this. Is it possible to get some verbose output from the generation script?

youngchen7 commented 2 years ago

We ran into this issue as well! And to debug we made this change: https://github.com/trumbitta/nx-trumbitta/pull/71

However, for some really really strange reason, logging it seems to make it work again. Maybe it's some interaction with the spawned child process handlers? Perhaps the spawned child process hangs waiting for the stdout buffer to flush?

In any case, you can try this out by locally installing the package from that branch.

youngchen7 commented 2 years ago

Perhaps this thread: https://stackoverflow.com/questions/20792427/why-is-my-node-child-process-that-i-created-via-spawn-hanging is related

trumbitta commented 2 years ago

Yup, seems related and the fix from #71 checks out!

I never experienced this issue myself (every time it hangs for me is because of a misconfiguration or because it's unable to reach a remotely published spec file) but I'd ✨ happily ✨ merge #71 when it's ready!

iceteabottle commented 2 years ago

Thanks @youngchen7! It doesn't hang anymore.