From 6f67814eb45725bc7f3736a2638bad0a7470f17a Mon Sep 17 00:00:00 2001 From: Maximilian Krambach Date: Thu, 3 May 2018 14:12:10 +0200 Subject: js: changed Key class stub -- * src/Key.js: A Key object cannot offer more than basic functionality outside a connection, so it now requires a connection to be present. --- lang/js/src/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lang/js/src/index.js') diff --git a/lang/js/src/index.js b/lang/js/src/index.js index 90fe99e3..fc406c66 100644 --- a/lang/js/src/index.js +++ b/lang/js/src/index.js @@ -36,9 +36,12 @@ function init(config){ return new Promise(function(resolve, reject){ let connection = new Connection; // TODO: Delayed reaction is ugly. We need to listen to the port's - // event listener in isConnected, but this takes some time (<5ms) to - // disconnect if there is no successfull connection. + // event listener in isConnected, but in some cases this takes some + // time (<5ms) to disconnect if there is no successfull connection. let delayedreaction = function(){ + if (connection === undefined) { + reject(gpgme_error('CONN_NO_CONNECT')); + } if (connection.isConnected === true){ if (_conf.api_style && _conf.api_style === 'gpgme_openpgpjs'){ resolve(new GpgME_openpgpmode(connection, _conf)); -- cgit v1.2.3