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

Can't open Nx Generate UI on Intellij :( #2071

Closed
renatoaraujoc opened this issue Mar 27, 2024 · 8 comments
Closed

Can't open Nx Generate UI on Intellij :( #2071

renatoaraujoc opened this issue Mar 27, 2024 · 8 comments
Assignees
Labels
blocked: more info needed more info needed type: bug Something isn't working

Comments

@renatoaraujoc
Copy link

Hello,

I'm not being able to open up Generate UI in my Intellij IDEA Ultimate, this probably happened after some migration from version X to Y, I'm currently using the latest version of Nx and latest version of Nx Console. I was able to sort of pin point the issue by inspecting the nx-console code.

Nx Report

 NX   Report complete - copy this into the issue template

Node   : 20.11.0
OS     : darwin-arm64
yarn   : 1.22.19

nx (global)        : 18.1.3
nx                 : 18.1.3
@nx/js             : 18.1.3
@nx/jest           : 18.1.3
@nx/linter         : 18.1.3
@nx/eslint         : 18.1.3
@nx/workspace      : 18.1.3
@nx/angular        : 18.1.3
@nx/cypress        : 18.1.3
@nx/devkit         : 18.1.3
@nx/esbuild        : 18.1.3
@nx/eslint-plugin  : 18.1.3
@nx/nest           : 18.1.3
@nx/node           : 18.1.3
@nx/plugin         : 18.1.3
@nx/storybook      : 18.1.3
@nrwl/tao          : 18.1.3
@nx/vite           : 18.1.3
@nx/web            : 18.1.3
@nx/webpack        : 18.1.3
typescript         : 5.3.3
---------------------------------------
Community plugins:
@analogjs/vite-plugin-angular : 1.0.2
@k11r/nx-cloudflare-wrangler  : 2.9.1
@ngneat/transloco             : 4.3.0
@ngrx/component-store         : 17.0.1
@ngrx/effects                 : 17.0.1
@ngrx/entity                  : 17.0.1
@ngrx/router-store            : 17.0.1
@ngrx/schematics              : 17.0.1
@ngrx/store                   : 17.0.1
@ngrx/store-devtools          : 17.0.1
@nguniversal/builders         : 16.2.0
@nguniversal/express-engine   : 16.2.0
@ngx-env/builder              : 17.2.3
@ngxs/schematics              : 0.0.1-alpha.5
@nx-tools/nx-prisma           : 5.2.0
@rx-angular/cdk               : 17.0.1
@rx-angular/state             : 17.0.1
@rx-angular/template          : 17.0.1
@storybook/angular            : 7.5.3
ngx-spinner                   : 12.0.0
ngxtension                    : 0.3.3

Versions:

Nx Console: 1.20.0
Intellij IDEA Version: IntelliJ IDEA 2024.1 RC (Ultimate Edition) (Build #IU-241.14494.158, built on March 21, 2024)

The error:

Unhandled exception in [ComponentManager(ProjectImpl@504070726), CoroutineName(dev.nx.console.generate.NxGenerateService), StandaloneCoroutine{Cancelling}@dabb6be, Dispatchers.Default]

org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Request nx/generators failed with message: The "paths[2]" argument must be of type string. Received undefined
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:209)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)
	at dev.nx.console.nxls.NxlsWrapper.start$lambda$7$lambda$6(NxlsWrapper.kt:98)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [ComponentManager(ProjectImpl@504070726), CoroutineName(dev.nx.console.generate.NxGenerateService), StandaloneCoroutine{Cancelled}@dabb6be, Dispatchers.Default]

Looks like the error happens here:

Screenshot 2024-03-27 at 00 30 52

I found the location of error above by inspecting idea.log, the language server throws this message before the exception is thrown at the Intellij's error window.

The weird issue is that Nx Console is working everywhere except my main project, this was probably due to some nx migrate maybe. Since the error is not very informative, I cannot have a clue where to look to find the "paths[2]" that was supposed to be a string but received undefined.

@renatoaraujoc renatoaraujoc added the type: bug Something isn't working label Mar 27, 2024
@MaxKless
Copy link
Collaborator

Do you have a repro I can try this on?
Because otherwise the exact cause will be very hard for me to pin down.
Alternatively you could clone Nx Console and add some logging. Then we can collab on a fix :)

@renatoaraujoc
Copy link
Author

renatoaraujoc commented Mar 27, 2024

Hey @MaxKless,

The repo I'm using and the only one causing this issue is private, it's the companies' repo.

The weirdest part is that nx generator in the cli works perfectly, everything works, except the Generate UI, btw I also checked my VSCode Generate UI doesn't work as well for this project.

Could you provide me the basics steps to compile the Nx Console (Language server + plugin) so I can log it here?

I'll do my best to fix it and then come back with issue for you and maybe even provide some feedback with what could be improved in the logging itself so my case is easier to identify for others that may suffer from this issue.

Renato

@MaxKless
Copy link
Collaborator

MaxKless commented Apr 2, 2024

Thanks for the willingness to help out! It makes sense that the CLI works and the UI doesn't. You can see that this error is happening during the nx/generators request which is where the nxls computes what generators are available in the workspace. It's different logic from nx which just looks up a specific generator.

Spinning up Nx Console in IntelliJ is easy. You just clone the repo, run yarn and use this runIde gradle task to run a development instance of intellij with your local changes
image

You can find the code for the generators request under libs/language-server/workspace/src/lib/get-generators.ts. You can add some logging by importing lspLogger from @nx-console/language-server/utils. There you can check at what point your code errors.

I'm super grateful for your help and look forward to what you find out!

@renatoaraujoc
Copy link
Author

Hey @MaxKless,

I'll start this debug soon, will keep you informed, thanks for the input!

@renatoaraujoc
Copy link
Author

Hey @MaxKless, good news, I found the issue (and actually fixed the Nx Generate UI here by removing the package)!

First off, it was nothing related to my Nx Workspace at all (thanks God) but actually it's related to an external dependecy called @angular-builders/dev-server@7.3.1.

I pin-pointed the exact location where it throws the error so it can help you maybe patch the Nx Console. Since I'm not an Nx Console expert, I can't actually provide any fix but I can help you by showing where it happens.

  1. You can start by installing @angular-builders/dev-server@7.3.1.

  2. Then exactly here, this is where the issue happens:
    Screenshot 2024-04-06 at 04 01 24

I hope my help is of some use, I believe this is related to Project Crystal since you guys are now "inferring" stuff automatically and this is some sort of edge case.

Renato

@MaxKless
Copy link
Collaborator

MaxKless commented Apr 8, 2024

This is super helpful, thank you. I'll try to repro soon :) Can you fix it by upgrading the dependency?

@renatoaraujoc
Copy link
Author

This is super helpful, thank you. I'll try to repro soon :) Can you fix it by upgrading the dependency?

That was a last version of that depedency, I didn't need that custom webpack builder anymore since I ported all my Angular projects to Vite using AnalogJS's plugins.

And you're welcome! :)

@MaxKless
Copy link
Collaborator

MaxKless commented May 6, 2024

Hey! I just saw that this package was last published 5 years ago... so I'm not going to take the time to debug & fix this.

Still, thank you so much for the work you put in to identify the issue & I'm glad you got it resolved for yourself!

@MaxKless MaxKless closed this as completed May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked: more info needed more info needed type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants