Skip to content

Instantly share code, notes, and snippets.

@iperdomo
Last active Dec 6, 2018
Embed
What would you like to do?
Connection timeout
diff --git a/calva/state.ts b/calva/state.ts
index 447e46a..f7a748e 100644
--- a/calva/state.ts
+++ b/calva/state.ts
@@ -47,7 +47,8 @@ function config() {
projectRootDirectory: projectRootDirectoryConfig.replace(/^\/|\/$/g, ""),
jokerPath: configOptions.get("jokerPath"),
useJokerOnWSL: configOptions.get("useJokerOnWSL"),
- syncReplNamespaceToCurrentFile: configOptions.get("syncReplNamespaceToCurrentFile")
+ syncReplNamespaceToCurrentFile: configOptions.get("syncReplNamespaceToCurrentFile"),
+ connectionTimeout: configOptions.get("connectionTimeout")
};
}
diff --git a/lib-src/calva/repl/nrepl.cljs b/lib-src/calva/repl/nrepl.cljs
index 6c882ea..a5de935 100644
--- a/lib-src/calva/repl/nrepl.cljs
+++ b/lib-src/calva/repl/nrepl.cljs
@@ -9,11 +9,12 @@
(def CONTINUATION_ERROR_MESSAGE
"Unexpected continuation: \"")
+(def DEFAULT_TIMEOUT "Default timeout in milliseconds" (* 60 1000))
(defn connect
"Connects to a socket-based REPL at the given host (defaults to localhost) and port."
- [{:keys [host port on-connect on-error on-end] :or {host "localhost"}}]
- (doto (net/createConnection #js {:host host :port port})
+ [{:keys [host port on-connect on-error on-end timeout] :or {host "localhost" timeout DEFAULT_TIMEOUT}}]
+ (doto (net/createConnection #js {:host host :port port :timeout timeout})
(.once "connect" (fn []
#_(js/console.log (str "Connected to " host ":" port))
(when on-connect
diff --git a/package.json b/package.json
index 136db44..e2a9feb 100644
--- a/package.json
+++ b/package.json
@@ -123,6 +123,11 @@
"type": "boolean",
"default": false,
"description": "Specifies if Joker will run through WSL"
+ },
+ "calva.connectionTimeout": {
+ "type": "number",
+ "default": 60000,
+ "description": "Sets the connection timeout (in milliseconds)"
}
}
},
@@ -363,4 +368,4 @@
"shadow-cljs": "^2.4.8",
"typescript": "^2.9.2"
}
-}
\ No newline at end of file
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment