From 15a2acbc376722125af32191455643c1739872b6 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Tue, 5 Oct 2021 14:35:05 +0530 Subject: [PATCH 1/2] added try-catch --- packages/trie/src/readStream.ts | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/packages/trie/src/readStream.ts b/packages/trie/src/readStream.ts index 63515cdbaa..6f50155fda 100644 --- a/packages/trie/src/readStream.ts +++ b/packages/trie/src/readStream.ts @@ -18,15 +18,23 @@ export class TrieReadStream extends Readable { return } this._started = true - await this.trie._findValueNodes(async (nodeRef, node, key, walkController) => { - if (node !== null) { - this.push({ - key: nibblesToBuffer(key), - value: node.value, - }) - walkController.allChildren(node, key) - } - }) + try { + await this.trie._findValueNodes(async (nodeRef, node, key, walkController) => { + if (node !== null) { + this.push({ + key: nibblesToBuffer(key), + value: node.value, + }) + walkController.allChildren(node, key) + } + }) + } catch (error: any) { + if (error.message == 'Missing node in DB') { + // pass + } else { + throw error + } + } this.push(null) } } From accf029b01da5a148f27c13b3e0d2ab5511f9597 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Tue, 5 Oct 2021 18:48:05 +0530 Subject: [PATCH 2/2] linting fix --- packages/trie/src/readStream.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/trie/src/readStream.ts b/packages/trie/src/readStream.ts index 6f50155fda..8349f69074 100644 --- a/packages/trie/src/readStream.ts +++ b/packages/trie/src/readStream.ts @@ -29,11 +29,11 @@ export class TrieReadStream extends Readable { } }) } catch (error: any) { - if (error.message == 'Missing node in DB') { - // pass - } else { - throw error - } + if (error.message == 'Missing node in DB') { + // pass + } else { + throw error + } } this.push(null) }