From e53124e5d128864adbf8f4d6205bff75618147e5 Mon Sep 17 00:00:00 2001 From: Pavel Murygin Date: Thu, 3 Jun 2021 14:02:05 +0300 Subject: [PATCH 1/7] Fix the way version incompatibility is checked --- src/internal/FluenceConnection.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/internal/FluenceConnection.ts b/src/internal/FluenceConnection.ts index 09753ba82..ff463d596 100644 --- a/src/internal/FluenceConnection.ts +++ b/src/internal/FluenceConnection.ts @@ -128,7 +128,11 @@ export class FluenceConnection { try { await this.node.dial(this.address); } catch (e) { - if (e.name === 'AggregateError' && e._errors[0].code === 'ERR_ENCRYPTION_FAILED') { + if ( + e.name === 'AggregateError' && + e._errors[0].code === 'ERR_ENCRYPTION_FAILED' && + e._errors[0].message === 'protocol selection failed' + ) { throw new VersionIncompatibleError(); } } From bdc26d58cf17afa21764c21bd959890903c35fc8 Mon Sep 17 00:00:00 2001 From: Pavel Murygin Date: Thu, 3 Jun 2021 14:22:38 +0300 Subject: [PATCH 2/7] throwing other errors --- src/internal/FluenceConnection.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/internal/FluenceConnection.ts b/src/internal/FluenceConnection.ts index ff463d596..ccf0dc87d 100644 --- a/src/internal/FluenceConnection.ts +++ b/src/internal/FluenceConnection.ts @@ -134,6 +134,8 @@ export class FluenceConnection { e._errors[0].message === 'protocol selection failed' ) { throw new VersionIncompatibleError(); + } else { + throw e; } } From df8a697bf419de89022467e7d2578e9ec618f0d2 Mon Sep 17 00:00:00 2001 From: Pavel Murygin Date: Thu, 3 Jun 2021 14:30:12 +0300 Subject: [PATCH 3/7] Another way to display error message --- src/internal/FluenceConnection.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/internal/FluenceConnection.ts b/src/internal/FluenceConnection.ts index ccf0dc87d..68a5c95a0 100644 --- a/src/internal/FluenceConnection.ts +++ b/src/internal/FluenceConnection.ts @@ -128,12 +128,9 @@ export class FluenceConnection { try { await this.node.dial(this.address); } catch (e) { - if ( - e.name === 'AggregateError' && - e._errors[0].code === 'ERR_ENCRYPTION_FAILED' && - e._errors[0].message === 'protocol selection failed' - ) { - throw new VersionIncompatibleError(); + if (e.name === 'AggregateError' && e._errors[0].length === 1) { + const error = e._errors[0]; + throw `Error dialing node ${this.address}: ${error.code} ${error.message}`; } else { throw e; } From c580ddafb0d2cdbbc7eadc45cccee5ca7104e1ed Mon Sep 17 00:00:00 2001 From: Pavel Murygin Date: Thu, 3 Jun 2021 14:38:31 +0300 Subject: [PATCH 4/7] fix error --- src/internal/FluenceConnection.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal/FluenceConnection.ts b/src/internal/FluenceConnection.ts index 68a5c95a0..7b641eb29 100644 --- a/src/internal/FluenceConnection.ts +++ b/src/internal/FluenceConnection.ts @@ -128,7 +128,7 @@ export class FluenceConnection { try { await this.node.dial(this.address); } catch (e) { - if (e.name === 'AggregateError' && e._errors[0].length === 1) { + if (e.name === 'AggregateError' && e._errors.length === 1) { const error = e._errors[0]; throw `Error dialing node ${this.address}: ${error.code} ${error.message}`; } else { From 450b2072fd5588177887040ecaedea9572a7fe18 Mon Sep 17 00:00:00 2001 From: Pavel Murygin Date: Thu, 3 Jun 2021 14:48:29 +0300 Subject: [PATCH 5/7] add newlines --- src/internal/FluenceConnection.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/internal/FluenceConnection.ts b/src/internal/FluenceConnection.ts index 7b641eb29..41212ac89 100644 --- a/src/internal/FluenceConnection.ts +++ b/src/internal/FluenceConnection.ts @@ -130,7 +130,9 @@ export class FluenceConnection { } catch (e) { if (e.name === 'AggregateError' && e._errors.length === 1) { const error = e._errors[0]; - throw `Error dialing node ${this.address}: ${error.code} ${error.message}`; + throw `Error dialing node ${this.address}: +${error.code} +${error.message}`; } else { throw e; } From d62fa69a26f49dee8a5a11a30bb93398048d4feb Mon Sep 17 00:00:00 2001 From: Pavel Murygin Date: Thu, 3 Jun 2021 14:58:04 +0300 Subject: [PATCH 6/7] remove unused error class --- src/internal/FluenceConnection.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/internal/FluenceConnection.ts b/src/internal/FluenceConnection.ts index 41212ac89..61dc3953d 100644 --- a/src/internal/FluenceConnection.ts +++ b/src/internal/FluenceConnection.ts @@ -54,15 +54,6 @@ export interface FluenceConnectionOptions { dialTimeout?: number; } -export class VersionIncompatibleError extends Error { - __proto__: Error; - constructor() { - const trueProto = new.target.prototype; - super('Current version of JS SDK is incompatible with the connected Fluence node. Please update JS SDK'); - this.__proto__ = trueProto; - } -} - export class FluenceConnection { private readonly selfPeerId: PeerId; private node: Peer; From 0ee725702dfef7758664b06676ff793980aaa06b Mon Sep 17 00:00:00 2001 From: Pavel Murygin Date: Thu, 3 Jun 2021 15:23:30 +0300 Subject: [PATCH 7/7] \n s --- src/internal/FluenceConnection.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/internal/FluenceConnection.ts b/src/internal/FluenceConnection.ts index 61dc3953d..b0f25ddd9 100644 --- a/src/internal/FluenceConnection.ts +++ b/src/internal/FluenceConnection.ts @@ -121,9 +121,7 @@ export class FluenceConnection { } catch (e) { if (e.name === 'AggregateError' && e._errors.length === 1) { const error = e._errors[0]; - throw `Error dialing node ${this.address}: -${error.code} -${error.message}`; + throw `Error dialing node ${this.address}:\n${error.code}\n${error.message}`; } else { throw e; }