hardhat-vscode icon indicating copy to clipboard operation
hardhat-vscode copied to clipboard

Range exceptioning on bad inputs

Open sentry[bot] opened this issue 3 years ago • 5 comments
trafficstars

Sentry Issue: VSCODE-EXTENSION-1QN

Error: Range#create called with invalid arguments[[object Object], [object Object], undefined, undefined]
  File "/Users/pvu/.vscode/extensions/nomicfoundation.hardhat-solidity-0.2.0/server/out/index.js", line 31, in Object.Ki [as create]
    '{snip} s,Ri)};if(s.is(mi)&&s.is(Nn))return{start:mi,end:Nn};throw new Error("Range#create called with invalid arguments["+mi+", "+Nn+", "+gs+", "+R {snip}
  File "/Users/pvu/.vscode/extensions/nomicfoundation.hardhat-solidity-0.2.0/server/out/index.js", line 1722, in Mre
    '{snip} .character-r.length};return j20.TextEdit.replace(j20.Range.create(a,n),x)}function Mwx(x,n,r){let{rootPath:a,documentsAnalyzer:s}=r;return a {snip}
  File "/Users/pvu/.vscode/extensions/nomicfoundation.hardhat-solidity-0.2.0/server/out/index.js", line 1722, in <anonymous>
    '{snip} Analyzer:s})).map(f=>{let d=Vwx(f);return{label:d,textEdit:Mre(d,x,n),kind:M1.CompletionItemKind.Module,documentation:"Imports the package"} {snip}
  File "/Users/pvu/.vscode/extensions/nomicfoundation.hardhat-solidity-0.2.0/server/out/index.js", line 1722, in Mwx
    '{snip} mentsAnalyzer:s},n):jre({rootPath:a,documentsAnalyzer:s})).map(f=>{let d=Vwx(f);return{label:d,textEdit:Mre(d,x,n),kind:M1.CompletionItemKin {snip}
  File "/Users/pvu/.vscode/extensions/nomicfoundation.hardhat-solidity-0.2.0/server/out/index.js", line 1722, in Rre
    '{snip} wx(r);return f.concat(d)}else return Bwx(s)?Bre(x,s,u,n,a):Mwx(x,s,r)}function Bwx(x){return x.startsWith(".")}function Bre(x,n,r,a,s){if(/[ {snip}
...
(5 additional frame(s) were not displayed)

We are doing a range conversion that is throwing on bad inputs.

sentry[bot] avatar Mar 31 '22 09:03 sentry[bot]

This issue is also being tracked on Linear.

We use Linear to manage our development process, but we keep the conversations on Github.

LINEAR-ID: 6ff8371d-d1a0-4b34-82bf-bde8708d28be

github-actions[bot] avatar Mar 31 '22 09:03 github-actions[bot]

We are still seeing this in the sentry logs.

@OmarTawfik raised the point this may be related to some errors returned from solc not having source locations (i.e. error.sourceLocation). If that is the case we should deal errors of this sort as their own case, and eliminate the source of the bad inputs.

kanej avatar May 11 '23 09:05 kanej

I have a suspicion it is related to checks like these:

https://github.com/NomicFoundation/hardhat-vscode/blob/9cfb24bb204bdab9b6f58f7598467205cc401887/server/src/services/validation/DiagnosticConverter.ts#L76-L82

https://github.com/NomicFoundation/hardhat-vscode/blob/9cfb24bb204bdab9b6f58f7598467205cc401887/server/src/compilerDiagnostics/conversions/constrainByRegex.ts#L10-L12

I wonder if we should treat such locations as [0,0] instead of throwing/failing? Looks to me like it will still be an improvement to the end-user experience.

OmarTawfik avatar May 12 '23 02:05 OmarTawfik

@kanej This error is from 0.5.4 and earlier. Since then I've changed the import path completions logic and we don't have occurrences of this error on newer versions. Should I close the issue ?

antico5 avatar May 18 '23 12:05 antico5

@kanej This error is from 0.5.4 and earlier. Since then I've changed the import path completions logic and we don't have occurrences of this error on newer versions. Should I close the issue ?

Sentry is confusing on these sorts of thing. It doesn't necessarily merge new instances with the old version.

The Range#create exception is still happening: https://nomic-labs.sentry.io/issues/3758407495/?project=5469451&query=is%3Aunresolved+create&referrer=issue-stream&statsPeriod=14d&stream_index=0

kanej avatar May 22 '23 10:05 kanej