Skip to content

fix: call sendFolderConfigs synchronously after login [IDE-1901]#1194

Draft
nick-y-snyk wants to merge 2 commits intorefactor/IDE-1786_folder-config-refactoringfrom
fix/IDE-1901-sast-not-enabled-after-login
Draft

fix: call sendFolderConfigs synchronously after login [IDE-1901]#1194
nick-y-snyk wants to merge 2 commits intorefactor/IDE-1786_folder-config-refactoringfrom
fix/IDE-1901-sast-not-enabled-after-login

Conversation

@nick-y-snyk
Copy link
Copy Markdown
Contributor

@nick-y-snyk nick-y-snyk commented Apr 7, 2026

Description

Fixes a race condition where the first scan after login fails with "Snyk Code is not enabled" error.

sendFolderConfigs() was called as a background goroutine (go sendFolderConfigs(...)) after authentication. The login command returned immediately, the IDE got notified of auth success and triggered a scan — but SAST settings hadn't been fetched yet. On the next scan, settings were cached and it worked.

The fix removes the go keyword so sendFolderConfigs runs synchronously before returning the token. This is consistent with HandleFolders() which already calls it synchronously.

Jira: IDE-1901

Checklist

  • Tests added and all succeed
  • Regenerated mocks, etc. (make generate)
  • Linted (make lint-fix)
  • README.md updated, if user-facing
  • License file updated, if new 3rd-party dependency is introduced

sendFolderConfigs was called as a background goroutine after
authentication, causing a race condition where the IDE would trigger
a scan before SAST settings were fetched and cached. This resulted
in a "Snyk Code is not enabled" error on the first scan after login.

Running sendFolderConfigs synchronously ensures SAST settings are
populated before the login command returns, which is consistent with
how HandleFolders already calls sendFolderConfigs.
@snyk-io
Copy link
Copy Markdown

snyk-io bot commented Apr 7, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

The $/snyk.hasAuthenticated notification is sent via an async channel
inside Authenticate(), so the IDE can react and trigger a scan before
feature flags and SAST settings are populated. This caused "Snyk Code
is not enabled" errors on the first scan after login.

Add a postCredentialUpdateHook to AuthenticationService that runs after
credentials are stored but before the notification is sent. The login
command uses this hook to populate feature flags for all workspace
folders, ensuring SAST settings are cached before the IDE can scan.

Also extract populateAllFolderConfigs from buildLspFolderConfigs to
avoid duplicated PopulateFolderConfig calls.
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.

1 participant