wix-incubator / vscode-glean

The extension provides refactoring tools for your React codebase
MIT License
1.46k stars 56 forks source link

TypeError: Cannot read property 'superClass' of undefined #43

Closed capaj closed 5 years ago

capaj commented 5 years ago

https://github.com/wix/vscode-glean/blob/7d6791f9595bb9be4e5619f566c7c67276599d87/src/modules/jsx.ts#L166

I think that line needs another guard because I am seeing:

ERR Cannot read property 'superClass' of undefined: TypeError: Cannot read property 'superClass' of undefined
    at isSupportedComponent (/home/capaj/.vscode/extensions/wix.glean-4.2.3/out/modules/jsx.js:152:28)
    at Object.isStatefulComp (/home/capaj/.vscode/extensions/wix.glean-4.2.3/out/modules/jsx.js:158:9)
    at CompleteActionProvider.provideCodeActions (/home/capaj/.vscode/extensions/wix.glean-4.2.3/out/extension.js:33:19)
    at /usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:509:787
    at /usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:114:65
    at new Promise (<anonymous>)
    at Object.t.asThenable (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:114:33)
    at e.provideCodeActions (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:509:746)
    at /usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:524:308
    at e._withAdapter (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:520:234)
    at e.$provideCodeActions (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:524:270)
    at t._doInvokeHandler (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:609:757)
    at t._invokeHandler (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:609:423)
    at t._receiveRequest (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:607:973)
    at t._receiveOneMessage (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:606:957)
    at /usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:604:773
    at /usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:103:886
    at e.fire (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:105:344)
    at a (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:156:881)
    at Socket._socketDataListener (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:157:95)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at Pipe.onread (net.js:594:20)

The code I am looking at is just a simple stateless component.

Version 4.2.3

borislit commented 5 years ago

@capaj Wow ! first of all, thanks for the PR and the issue! Can you please post the snippet you've tried to refactor? Thanks!

capaj commented 5 years ago

I actually get this error whenever I focus any code at all. It doesn't even have to be a stateless component. I got it even with a bash script, with html template, with whatever you can think of.

borislit commented 5 years ago

I see. Does it happen when you select a valid component though? If so, can u post a snippet?

eastcoastcoder commented 5 years ago

Getting this problem as well. Downgraded to 4.2.2 just to to see if an older version helps. It gives the same error so I think it might either be a problem with a new VSCode update or a conflicting extension.

petekp commented 5 years ago

Also getting this error with VSCode 1.32.3 during app startup / initial extension activation. Using TypeScript. Glean doesn't appear to load at all, at least the commands aren't available.

[2019-03-29 12:43:36.449] [exthost] [error] [wix.glean] provider FAILED
[2019-03-29 12:43:36.450] [exthost] [error] TypeError: Cannot read property 'superClass' of undefined
    at isSupportedComponent (/Users/petepetrash/.vscode/extensions/wix.glean-4.10.1/out/modules/stateful-to-stateless.js:303:28)
    at Object.isStatefulComp (/Users/petepetrash/.vscode/extensions/wix.glean-4.10.1/out/modules/stateful-to-stateless.js:310:9)
    at CompleteActionProvider.provideCodeActions (/Users/petepetrash/.vscode/extensions/wix.glean-4.10.1/out/extension.js:39:37)
    at define.provideCodeActions.a.asPromise (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:564:641)
    at t.asPromise.Promise (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:48:58)
    at new Promise (<anonymous>)
    at Object.t.asPromise (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:48:32)
    at I.provideCodeActions (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:564:612)
    at define.$provideCodeActions._withAdapter.e (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:580:417)
    at $._withAdapter (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:575:502)
    at $provideCodeActions (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:580:395)
    at h._doInvokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:593:118)
    at h._invokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:592:777)
    at h._receiveRequest (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:591:383)
    at h._receiveOneMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:590:279)
    at define.constructor._protocol.onMessage.e (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:588:565)
    at u.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:43:254)
    at e (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:39:64)
    at u.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:43:254)
    at s (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:168:754)
    at Socket.define.constructor._socketDataListener.e (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:168:960)
    at Socket.emit (events.js:182:13)
    at Socket.EventEmitter.emit (domain.js:442:20)
    at addChunk (_stream_readable.js:279:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at Socket.Readable.push (_stream_readable.js:219:10)
    at Pipe.onread (net.js:636:20)
[2019-03-29 12:43:36.725] [exthost] [info] ExtensionService#_doActivateExtension vscode.extension-editing {"startup":false,"activationEvent":"onLanguage:typescript"}
[2019-03-29 12:43:36.725] [exthost] [info] ExtensionService#loadCommonJSModule /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/extension-editing/dist/extension
borislit commented 5 years ago

Hey @petekp , can you post the snipper u've tried refactoring?

petekp commented 5 years ago

@borislit I'm unable to use the plugin — the commands aren't accessible / don't show up since the plugin doesn't appear to load when my extensions are activated.

borislit commented 5 years ago

@petekp hmmm odd. Can you post the React snipper u've tried to refactor?

TimCluyts commented 5 years ago

Having the same issue here on React memo's

const Rows = memo(({ customer }) => { return <span>some layout stuff</span> }

[renderer1] [error] Cannot read property 'superClass' of undefined: TypeError: Cannot read property 'superClass' of undefined

borislit commented 5 years ago

@timcluyts You are getting this error when You select the snippet?

TimCluyts commented 5 years ago

@borislit When I put my cursor on memo, but even when I just open the file itself. Additionally I get following error too:

[2019-04-09 10:25:57.544] [exthost] [error] TypeError: Cannot read property 'selection' of undefined at Object.selectedText (c:\Users\****\.vscode\extensions\wix.glean-4.10.1\out\editor.js:37:30) at CompleteActionProvider.provideCodeActions (c:\Users\****\.vscode\extensions\wix.glean-4.10.1\out\extension.js:17:31) at define.provideCodeActions.a.asPromise (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:587:847) at t.asPromise.Promise (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:49:430) at new Promise (<anonymous>)

This is just on top of the superclass of undefined

borislit commented 5 years ago

@timcluyts Ok, I can reproduce! The fix is on its way :)

borislit commented 5 years ago

:tada: This issue has been resolved in version 4.10.2 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

borislit commented 5 years ago

@timcluyts can you verify the issue is resolved? Also, full credit for the fix goes to @capaj ! My bad I haven't merged this earlier!

borislit commented 5 years ago

@timcluyts BTW, What refactoring did you try to perform on the memo component? Perhaps its something we should support

TimCluyts commented 5 years ago

The issue on "superclass" has indeed been resolved. But - if you open the output window (Extension host) - and go to a memo class and put your cursor on "memo" it will still give the following: image

For that last question, the thing is that I did not in fact try to refactor. It just ended up in de output window when opening the file or selecting the memo itself. I only actually stumbled upon this issue because I was fighting with another one of my extensions and then, when enabling only Glean, I noticed these issues.

TimCluyts commented 5 years ago

I just created a fix for the issue described above.

TimCluyts commented 5 years ago

@borislit any chance of merging it? I am having to disable Glean because of these issues.

borislit commented 5 years ago

@timcluyts Sure. Ill review and merge right away

TimCluyts commented 5 years ago

@borislit https://github.com/wix/vscode-glean/pull/66

borislit commented 5 years ago

@timcluyts Done! Thanks for your contribution!