Skip to content

fix(intellij): read nx version under read action#3118

Open
MaxKless wants to merge 1 commit into
masterfrom
stylish-steed
Open

fix(intellij): read nx version under read action#3118
MaxKless wants to merge 1 commit into
masterfrom
stylish-steed

Conversation

@MaxKless

Copy link
Copy Markdown
Contributor

Wrap the synchronous Nx version fallback in an IntelliJ read action so background AI checks can parse package JSON PSI without threading assertions.

@nx-cloud-snapshot

nx-cloud-snapshot Bot commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit 7024639

Command Status Duration Result
nx affected --targets=lint,test,build,e2e-ci,ty... ❌ Failed 1m 5s View ↗
nx-cloud record -- node tools/scripts/check-pin... ✅ Succeeded <1s View ↗
nx-cloud record -- yarn nx sync:check ✅ Succeeded 11s View ↗
nx-cloud record -- yarn nx run-many -t ktfmtFormat ✅ Succeeded 4m 59s View ↗
nx run-many -t ktfmtFormat ✅ Succeeded 4m 53s View ↗
nx-cloud record -- yarn nx format:check --verbose ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-29 13:03:54 UTC

Comment on lines 49 to 51
return if (ApplicationManager.getApplication().isDispatchThread) {
nxVersion
} else {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent behavior between dispatch and non-dispatch threads. When nxVersion is null on the dispatch thread, it returns null immediately without trying fallback methods. However, on non-dispatch threads, it attempts fallbacks via tryGetNxVersionFromNodeModules() and tryGetNxVersionFromPackageJson(). This creates unpredictable behavior where the same call returns different results depending on which thread it's called from.

If the dispatch thread case also needs to try fallbacks when nxVersion is null, it should wrap the fallback logic in ApplicationManager.getApplication().runReadAction<NxVersion?> or use invokeLater to avoid blocking the EDT:

return if (ApplicationManager.getApplication().isDispatchThread) {
    nxVersion ?: ApplicationManager.getApplication().runReadAction<NxVersion?> {
        tryGetNxVersionFromNodeModules() ?: tryGetNxVersionFromPackageJson()
    }
} else {
    nxVersion ?: ApplicationManager.getApplication().runReadAction<NxVersion?> {
        tryGetNxVersionFromNodeModules() ?: tryGetNxVersionFromPackageJson()
    }
}

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

nx-cloud-snapshot[bot]

This comment was marked as outdated.

@nx-cloud-snapshot nx-cloud-snapshot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.

Nx Cloud has identified a possible root cause for your failed CI:

We investigated the CI failure and determined it is unrelated to this PR's changes. The build fails in Gradle's instrumentCode task due to a pre-existing implicit dependency on compileKotlin that Gradle 8.13 no longer permits, alongside a missing src/main/java directory that has never existed in this Kotlin-only project. The changed code compiled successfully (compileKotlin was UP-TO-DATE), confirming the fix itself is sound.

No code changes were suggested for this issue.

Trigger a rerun:

Rerun CI

Nx Cloud View detailed reasoning on Nx Cloud ↗


🎓 Learn more about Self-Healing CI on nx.dev

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants