aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js/src/Connection.js
diff options
context:
space:
mode:
authorMaximilian Krambach <[email protected]>2018-09-19 08:56:36 +0000
committerMaximilian Krambach <[email protected]>2018-09-19 08:56:36 +0000
commit7f149586062ebae8114f64078771cb25579f5003 (patch)
treeafb8f87c0a8195ce8cf320115edc80019c9fd0af /lang/js/src/Connection.js
parentdocs: python bindings (diff)
downloadgpgme-7f149586062ebae8114f64078771cb25579f5003.tar.gz
gpgme-7f149586062ebae8114f64078771cb25579f5003.zip
js: add configuration option on startup
-- * src/index.js: Added an optional configuration object for the startup. * configuration: timeout - the initial check for a connection ran into timeouts on slower testing machines. 500ms for initial startup is not sufficient everywhere. The default timeout was raised to 1000ms, and as an option this timeout can be increased even further. * BrowsertestExtension: Set the initial connection timeouts to 2 seconds, to be able to test on slower machines.
Diffstat (limited to 'lang/js/src/Connection.js')
-rw-r--r--lang/js/src/Connection.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/lang/js/src/Connection.js b/lang/js/src/Connection.js
index 4055da6a..d43d55f1 100644
--- a/lang/js/src/Connection.js
+++ b/lang/js/src/Connection.js
@@ -74,11 +74,15 @@ export class Connection{
* Retrieves the information about the backend.
* @param {Boolean} details (optional) If set to false, the promise will
* just return if a connection was successful.
+ * @param {Number} timeout (optional)
* @returns {Promise<backEndDetails>|Promise<Boolean>} Details from the
* backend
* @async
*/
- checkConnection (details = true){
+ checkConnection (details = true, timeout = 1000){
+ if (typeof timeout !== 'number' && timeout <= 0) {
+ timeout = 1000;
+ }
const msg = createMessage('version');
if (details === true) {
return this.post(msg);
@@ -90,7 +94,7 @@ export class Connection{
new Promise(function (resolve, reject){
setTimeout(function (){
reject(gpgme_error('CONN_TIMEOUT'));
- }, 500);
+ }, timeout);
})
]).then(function (){ // success
resolve(true);