MATLAB-extension-for-vscode icon indicating copy to clipboard operation
MATLAB-extension-for-vscode copied to clipboard

Error and warning detection stops working after a while

Open jecs opened this issue 10 months ago • 12 comments

Describe the bug After using VSCode for a while (usually 30 minutes+), ~~syntax highlighting~~ error and warning detection stops working (i.e. I get false positives and generic errors). The only way to remedy this issue is to "disconnect" from Matlab and then connect again. It seems that the instance tied to ~~syntax formatting~~ error and warning detection hangs or becomes unresponsive for some reason. Instances of Matlab remain open even after disconnecting, requiring force quitting the old instances.

To Reproduce Steps to reproduce the behavior:

  1. Use Matlab extension in VSCode for an extended period.
  2. Wait until error detection breaks.
  3. Disconnect and reconnect from Matlab to "fix" issue.

Expected behavior I would expect error and warning detection to work flawlessly and not to require constantly needing to disconnect and connect to new instances of Matlab.

Useful Information

  • MATLAB version: R2024b Update 3 (24.2.0.2803551)
  • OS Version: macOS 15.2 (24C101)
  • VS Code Version: Version: 1.96.3

Additional context This has been an issue for as long as I have used this extension. It happens even when using the ssh plugin to run the extension on a remote Linux server. It doesn't seem to be an issue with VSCode's version and it doesn't seem to be unique to macOS, though I guess that it could be a problem with the macOS VSCode client itself. I should also add that I am using the "New Desktop" addon in Matlab locally but not on the Linux machine.

jecs avatar Jan 16 '25 17:01 jecs

Hi @jecs , thanks for reporting this!

I haven't seen this myself, and it is odd that this is corrected by disconnecting/reconnecting to MATLAB. Syntax highlighting should be handled by VS Code natively, and nothing from the MATLAB application should be impacting syntax highlighting.

It does sound that MATLAB is occasionally freezing in some way, hence needing to force-quit old instances.

Can you please share the following:

  1. A screenshot of the syntax highlighting issue you are seeing
  2. Any generated output logs from a session which encountered this issue

dklilley avatar Jan 16 '25 18:01 dklilley

Hi, @dklilley.

Thanks for the prompt response.

Ah, I just realized that I did not describe the problem 100% accurately: It's not syntax highlighting itself but the highlighting of errors and warnings with yellow and red that stops working.

I will edit the title of this bug report. I will also send you a screenshot and logs when this issue pops up again (it can be quite random).

jecs avatar Jan 16 '25 18:01 jecs

That makes more sense, thanks for the clarification!

In the log directory, there should be a matlabLog.txt file - this may be helpful as it may show errors which occurred on the MATLAB side.

dklilley avatar Jan 16 '25 18:01 dklilley

The error has happened today, and I believe that the matlabLog.txt reflects that. I attach it here. The new instance of Matlab starts after disconnecting and then connecting midway in the file.

matlabLog.txt

I'll attach a screenshot or .gif when the issue pops up again.

jecs avatar Jan 16 '25 19:01 jecs

It happened again. Here I attach a .gif showing how the issue affects VSCode, the latest matlabLog.txt, and a small image showing the many instances of MATLAB.

Image

matlabLog.txt

Image

jecs avatar Jan 16 '25 22:01 jecs

Thanks for the extra information and the logs! Unfortunately, I don't see anything related in the logs, but it does seem that MATLAB might be hanging.

  • Have you encountered any issue with hangs while using MATLAB directly (not through the VS Code extension)?
  • Are you working within a workspace in VS Code? If so, approximately how many MATLAB files are within it?

dklilley avatar Jan 17 '25 15:01 dklilley

  • I have not encountered any issues with hangs while using MATLAB directly.
  • Yes, I am working within a workspace. Not too many. About 12 .m files, but I am only working on 2-3.

jecs avatar Jan 17 '25 15:01 jecs

~~That latest update might have fixed the issue. I will keep using the extension and let you know in a day or two whether the issue pops up again.~~

I spoke too soon. The issue just popped up again.

jecs avatar Jan 28 '25 17:01 jecs

Thanks for the confirmation. Something seems to be happening on the MATLAB side which is causing it to hang or otherwise become unresponsive. Unfortunately, I haven't been able to determine anything from the extension's logs.

I would suggest reaching out to MathWorks Support, as they will have other diagnostics which they can try.

dklilley avatar Jan 29 '25 15:01 dklilley

Thanks, @dklilley. I will reach out to them.

The request was assigned Case Number 07577589.

jecs avatar Jan 29 '25 15:01 jecs

I'm in the middle of working through this issue with support. No luck so far.

However, I did notice that the extension seems to have a bit of trouble with paths.

languageServerLog.txt

(12:48:14) matlabls: Launching MATLAB...
(12:48:17) matlabls: Started MATLAB (session 2)
(12:48:17) matlabls: MATLAB session 2 connected to R2024b
(12:48:17) matlabls: CWD set to: Users/josecs/dev/project
(12:48:17) matlabls: Adding workspace folder(s) to the MATLAB Path: 
	Users/josecs/dev/project

matlabLog.txt

...
matlabls: Beginning initialization
matlabls: matlabroot is 
/Applications/MATLAB_R2024b.app
Printing connection data to file:/var/folders/yt/zdf2yqds1sj8fg68_qqvy86h0000gq/T/matlabls_17115/matlabls_conn.json
matlabls: Initialization complete
Error during `cd` operation:
Unable to change current folder to '/Users/josecs/dev/project/Users/josecs/dev/project' (Name is nonexistent or not a folder).
[Warning: Name is nonexistent or not a directory:
/Users/josecs/dev/project/Users/josecs/dev/project]
[> In path (line 109)
In addpath>doPathAddition (line 126)
...

jecs avatar Jan 31 '25 18:01 jecs

Thanks for the update!

Regarding the issue with cd/addpath - this has also been reported inside MathWorks as well, and seems to be specific to Mac. I will create a new issue to track this.

dklilley avatar Feb 03 '25 21:02 dklilley