diff options
author | Maximilian Krambach <[email protected]> | 2018-04-25 09:32:21 +0000 |
---|---|---|
committer | Maximilian Krambach <[email protected]> | 2018-04-25 09:32:21 +0000 |
commit | 5befa1c9751fe54b5ae87906d7f09772ce9de6ea (patch) | |
tree | 07d5b2dd1f97c88d42cc5bf723be464ec97403cd /lang/js/src/Connection.js | |
parent | js: change in Error behaviour (diff) | |
download | gpgme-5befa1c9751fe54b5ae87906d7f09772ce9de6ea.tar.gz gpgme-5befa1c9751fe54b5ae87906d7f09772ce9de6ea.zip |
js: reactivate timeout on connection
--
* A timeout of 5 seconds is activated for functions that do not require
a pinentry. This definition is written to src/permittedOperations.js
* testapplication.js now alerts the proper error codes and messages.
* src/Errors.js fixed two typos in error handling
Diffstat (limited to 'lang/js/src/Connection.js')
-rw-r--r-- | lang/js/src/Connection.js | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lang/js/src/Connection.js b/lang/js/src/Connection.js index 8bc3d42a..4270be58 100644 --- a/lang/js/src/Connection.js +++ b/lang/js/src/Connection.js @@ -118,14 +118,18 @@ export class Connection{ }; me._connection.onMessage.addListener(listener); - me._connection.postMessage(message.message); - - //TBD: needs to be aware if there is a pinentry pending - // setTimeout( - // function(){ - // me.disconnect(); - // reject(GPGMEJS_Error('CONN_TIMEOUT')); - // }, timeout); + let timeout = new Promise(function(resolve, reject){ + setTimeout(function(){ + reject(GPGMEJS_Error('CONN_TIMEOUT')); + }, 5000); + }); + if (permittedOperations[message.operation].pinentry){ + return me._connection.postMessage(message.message); + } else { + return Promise.race([timeout, + me._connection.postMessage(message.message) + ]); + } }); } }; |