From d833c9745d989ce8ed64350b524fced461dfb6bf Mon Sep 17 00:00:00 2001 From: yann300 Date: Sun, 26 Apr 2020 13:13:15 +0200 Subject: [PATCH] make sure compilation result fn is used with `await` && check for `null` returns --- remix-debug/src/debugger/debugger.js | 2 ++ remix-lib/src/code/breakpointManager.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/remix-debug/src/debugger/debugger.js b/remix-debug/src/debugger/debugger.js index 3eb19bc19..0d294d578 100644 --- a/remix-debug/src/debugger/debugger.js +++ b/remix-debug/src/debugger/debugger.js @@ -24,6 +24,7 @@ function Debugger (options) { this.breakPointManager = new remixLib.code.BreakpointManager(this.debugger, async (sourceLocation) => { const compilationResult = await this.compilationResult() + if (!compilationResult) return { start: null, end: null } return this.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file, compilationResult.source.sources, compilationResult.data.sources) }, (step) => { this.event.trigger('breakpointStep', [step]) @@ -49,6 +50,7 @@ Debugger.prototype.registerAndHighlightCodeItem = function (index) { this.debugger.traceManager.getCurrentCalledAddressAt(index, async (error, address) => { if (error) return console.log(error) const compilationResultForAddress = await this.compilationResult(address) + if (!compilationResultForAddress) return this.debugger.callTree.sourceLocationTracker.getSourceLocationFromVMTraceIndex(address, index, compilationResultForAddress.data.contracts, (error, rawLocation) => { if (!error && compilationResultForAddress && compilationResultForAddress.data) { var lineColumnPos = this.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, compilationResultForAddress.source.sources, compilationResultForAddress.data.sources) diff --git a/remix-lib/src/code/breakpointManager.js b/remix-lib/src/code/breakpointManager.js index b45232f12..163cf703a 100644 --- a/remix-lib/src/code/breakpointManager.js +++ b/remix-lib/src/code/breakpointManager.js @@ -86,7 +86,7 @@ class BreakpointManager { console.log('cannot jump to breakpoint ' + e) return } - let lineColumn = this.locationToRowConverter(sourceLocation) + let lineColumn = await this.locationToRowConverter(sourceLocation) if (this.previousLine !== lineColumn.start.line) { if (direction === -1 && lineHadBreakpoint) { // TODO : improve this when we will build the correct structure before hand lineHadBreakpoint = false