Skip to content

Commit 5e9204c

Browse files
continue[bot]ContinueRomneyDa
authored
Fix IntelliJ remote config sync freeze and JSON parsing issues (#8801)
* Fix IntelliJ remote config sync issues - Only schedule sync job when remote server URL is configured - Catch all exceptions including JsonSyntaxException - Fix logic error where configJs and configJson overwrite each other - Properly clean up sync job when cancelled Fixes #8769 Co-authored-by: dallin <[email protected]> Generated with [Continue](https://continue.dev) Co-Authored-By: Continue <[email protected]> * Fix config.js and config.json file path separation Use separate file paths for JavaScript (config.js) and JSON (config.json) configuration files to maintain proper separation of concerns. Co-authored-by: dallin <[email protected]> Generated with [Continue](https://continue.dev) Co-Authored-By: Continue <[email protected]> --------- Co-authored-by: continue[bot] <continue[bot]@users.noreply.github.com> Co-authored-by: Continue <[email protected]> Co-authored-by: Dallin Romney <[email protected]>
1 parent 819f1d3 commit 5e9204c

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/services/ContinueExtensionSettingsService.kt

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.github.continuedev.continueintellijextension.services
22

33
import com.github.continuedev.continueintellijextension.constants.getConfigJsonPath
4+
import com.github.continuedev.continueintellijextension.constants.getConfigJsPath
45
import com.github.continuedev.continueintellijextension.error.ContinueSentryService
56
import com.google.gson.Gson
67
import com.intellij.openapi.application.ApplicationManager
@@ -122,29 +123,43 @@ open class ContinueExtensionSettings : PersistentStateComponent<ContinueExtensio
122123
connection.addRequestProperty("Authorization", "Bearer $token")
123124
}.readString()
124125
val response = Gson().fromJson(responseBody, ContinueRemoteConfigSyncResponse::class.java)
125-
val file = File(getConfigJsonPath(URL(url).host))
126-
response.configJs.let { file.writeText(it!!) }
127-
response.configJson.let { file.writeText(it!!) }
128-
} catch (e: IOException) {
126+
val hostname = URL(url).host
127+
128+
// Write configJson to config.json if present
129+
if (!response.configJson.isNullOrEmpty()) {
130+
File(getConfigJsonPath(hostname)).writeText(response.configJson!!)
131+
}
132+
133+
// Write configJs to config.js if present
134+
if (!response.configJs.isNullOrEmpty()) {
135+
File(getConfigJsPath(hostname)).writeText(response.configJs!!)
136+
}
137+
} catch (e: Exception) {
138+
// Catch all exceptions including JsonSyntaxException
129139
service<ContinueSentryService>().report(e, "Unexpected exception during remote config sync")
130140
}
131141
}
132142
}
133143

134144
// Create a scheduled task to sync remote config every `remoteConfigSyncPeriod` minutes
135145
fun addRemoteSyncJob() {
136-
146+
// Cancel existing job if present
137147
if (remoteSyncFuture != null) {
138148
remoteSyncFuture?.cancel(false)
149+
remoteSyncFuture = null
139150
}
140151

141-
instance.remoteSyncFuture = AppExecutorUtil.getAppScheduledExecutorService()
142-
.scheduleWithFixedDelay(
143-
::syncRemoteConfig,
144-
0,
145-
continueState.remoteConfigSyncPeriod.toLong(),
146-
TimeUnit.MINUTES
147-
)
152+
// Only schedule sync job if remote config server URL is configured
153+
val remoteServerUrl = continueState.remoteConfigServerUrl
154+
if (remoteServerUrl != null && remoteServerUrl.isNotEmpty()) {
155+
instance.remoteSyncFuture = AppExecutorUtil.getAppScheduledExecutorService()
156+
.scheduleWithFixedDelay(
157+
::syncRemoteConfig,
158+
0,
159+
continueState.remoteConfigSyncPeriod.toLong(),
160+
TimeUnit.MINUTES
161+
)
162+
}
148163
}
149164
}
150165

0 commit comments

Comments
 (0)