Skip to content

fix: Eliminate Uncaught TypeError in dev tools #4666

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

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.intellij.openapi.components.ServiceManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Disposer
import com.intellij.ui.jcef.*
import com.intellij.ui.jcef.JBCefClient.Properties
import org.cef.CefApp
import org.cef.browser.CefBrowser
import org.cef.handler.CefLoadHandlerAdapter
Expand All @@ -32,10 +33,16 @@ class ContinueBrowser(val project: Project, url: String) {
init {
val isOSREnabled = ServiceManager.getService(ContinueExtensionSettings::class.java).continueState.enableOSR

this.browser = JBCefBrowser.createBuilder().setOffScreenRendering(isOSREnabled).build()
this.browser = JBCefBrowser.createBuilder().setOffScreenRendering(isOSREnabled).build().apply {
// To avoid using System.setProperty to affect other plugins,
// we should configure JS_QUERY_POOL_SIZE after JBCefClient is instantiated,
// and eliminate the 'Uncaught TypeError: window.cefQuery_xxx is not a function' error
// in the JS debug console, which is caused by ContinueBrowser lazy loading.
jbCefClient.setProperty(Properties.JS_QUERY_POOL_SIZE, JS_QUERY_POOL_SIZE)
}

registerAppSchemeHandler()
browser.loadURL(url);
browser.loadURL(url)
Disposer.register(ContinuePluginDisposable.getInstance(project), browser)

// Listen for events sent from browser
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.intellij.openapi.wm.ToolWindowFactory
import com.intellij.ui.content.ContentFactory
import javax.swing.*

const val JS_QUERY_POOL_SIZE = "200"
const val JS_QUERY_POOL_SIZE = 200

class ContinuePluginToolWindowFactory : ToolWindowFactory, DumbAware {
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
Expand Down Expand Up @@ -43,11 +43,6 @@ class ContinuePluginToolWindowFactory : ToolWindowFactory, DumbAware {
class ContinuePluginWindow(project: Project) {
private val defaultGUIUrl = "http://continue/index.html"

init {
System.setProperty("ide.browser.jcef.jsQueryPoolSize", JS_QUERY_POOL_SIZE)
System.setProperty("ide.browser.jcef.contextMenu.devTools.enabled", "true")
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the line I'm referencing. It allows you to right click and "Open Dev Tools" which is very useful for debugging

}

val browser: ContinueBrowser by lazy {
val url = System.getenv("GUI_URL")?.toString() ?: defaultGUIUrl

Expand Down
Loading