Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read properties of undefined (reading 'project') #278

Closed
vladcristianmarin opened this issue May 21, 2024 · 5 comments · Fixed by #870
Closed

Cannot read properties of undefined (reading 'project') #278

vladcristianmarin opened this issue May 21, 2024 · 5 comments · Fixed by #870
Labels
bug Something isn't working

Comments

@vladcristianmarin
Copy link
Collaborator

vladcristianmarin commented May 21, 2024

Description
When I am launching the IDE window I receive the following error toast in vscode "Cannot read properties of undefined (reading 'project')" and also my log console and breakpoints do not work, I don't see anything attached to the console and breakpoints just do not work. I assume this is why, because of that error.

Environment

  • v0.0.10-beta
  • "react-native": "0.72.6" with expo ejected
@vladcristianmarin vladcristianmarin added the bug Something isn't working label May 21, 2024
@jakub-gonet
Copy link
Member

Can you please check for errors and stacktrace from dev tools directly in VSCode (Help > Toggle Developer Tools)?

@vladcristianmarin
Copy link
Collaborator Author

vladcristianmarin commented May 22, 2024

Screenshot 2024-05-22 at 14 21 08

[vscode-app-1716376879580.log] (https://github.com/software-mansion/react-native-ide/files/15402426/vscode-app-1716376879580.log)

TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope source.yaml.
Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/yaml/syntaxes/yaml.tmLanguage.json.
New grammar file: file:///Users/vlamarin/.vscode/extensions/redhat.vscode-yaml-1.14.0/syntaxes/yaml.tmLanguage.json
register @ TMScopeRegistry.ts:46
TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope source.yaml.
Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/yaml/syntaxes/yaml.tmLanguage.json.
New grammar file: file:///Users/vlamarin/.vscode/extensions/redhat.vscode-yaml-1.14.0/syntaxes/yaml.tmLanguage.json
register @ TMScopeRegistry.ts:46
log.ts:419 INFO Started local extension host with pid 51552.
log.ts:419 INFO [perf] Render performance baseline is 23ms
console.ts:137 [Extension Host] vscode
webviewElement.ts:482 An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing.
mountTo @ webviewElement.ts:482
notificationsAlerts.ts:40 Error: Cannot read properties of null (reading 'project')
at r.h (vscode-file://vscode-app/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:153:189812)
c @ notificationsAlerts.ts:40

@jakub-gonet
Copy link
Member

Hm. Do you have any project that reproduces this issue? You can try installing dev version from main (https://ide.swmansion.com/docs/development). This should give us better stack traces.

Either one will help, I can't repro the problem myself.

@janwiebe-jump
Copy link
Collaborator

I can reproduce it as follows:

npx create-expo-app StickerSmash --template blank && cd StickerSmash

Open the StickerSmash and open RN IDE panel.

Then I get this error. The thing I noted is that I have multiple VS Code windows with RN projects open.
In the debug console I see messages about the react-native-preview that things have already been registered (forgot the exact phrase).
When I close all other VS Code windows, restart my vs code, then the RN IDE works, and can launch my project in the integrated emulator

@jerone
Copy link

jerone commented Sep 26, 2024

Same issue:

Cannot read properties of null (reading 'project')

Literally nothing starts or opens after pressing "Open IDE Panel".
No logging in the Output window under "React Native IDE".

Developer Tools shows this (after clean):
image


  • Windows 11 23H2
  • VSCode 1.93.1
  • Radon IDE v0.0.19

maciekstosio added a commit that referenced this issue Jan 7, 2025
Fixes #278

This PR refactors logic related to opening previews. We were using
`showIDEPanel` for `RNIDE.showPanel`/`RNIDE.openPanel` commands, the
launch preview depended on the existence of the `fileName` and
`lineNumber`. The problem is that VSCode passes its arguments there, but
instead number in lineNumber we get an object with the panel's id, which
triggers this logic always. Thus, I refactored the opening preview to
use a separate command.

Additionally, startPreview was running even if the project wasn't set up
yet, which led to an error that we used `.project` on `null`. Now, we
open the panel and show a warning in that case.

### How Has This Been Tested: 

Repeat those scenarios for preview both in `tab panel` and `side panel`:

**Steps:**
- Close the IDE panel
- Reopen (or restart if in debug mode) VSCode 
- Open IDE panel from top right corner 

**Expected:**
The panel opens without error dialog. 

**Steps:**
- Close the IDE panel
- Reopen (or restart if in debug mode) VSCode 
- Click "Open preview" 

**Expected:**
Confirm that panel opens and there is warning message 

**Steps:**
- Make sure IDE Panel is open
- Click "Open preview" 

**Expected:**
Confirm that preview started

_Tested on react-native-76_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants