Take care while working with VS Code

While it seems a little offtopic, I wanted to post a warning here to alert anyone that uses Visual Studio Code on their developments. It happened to me something that I never expected nowadays: I lost all the work done in an entire new application I was developing.
I already opened an issue at the vsc github, and I expect it being useless. That is a quote for was happened:

Today I started Visual Studio Code and it opened by default the project I was working on yesterday. The project is a Vuejs web application, opened as a local folder, and not included into any version control. I noticed that as I clicked, two instances of VSCode where opened, that seemed equal to me, so I closed the one opened last.
When running the aplication I saw multiple errors that shouldn't be there, and when I checked the files all the changes for the last 24 hours where reverted.
No message was shown, no confirmation dialogs and no questions for actions. It simply ate the work.

I've always been a windows guy, my main system is a W10 and I always use Visual Studio (the full env) at work and on my private projects. Only recently started using Code in windows for Iot sketches, due to platformio. But three weeks ago installed kubuntu, and as I was lacking vs2017 I started to use code for anything.

This was a web application that I recently started and I worked very hard on it for the past week. I mean that I'm very moderate about the interval being lost. As it's a node/vue application, I can't say at the first glance if packages where also removed or if internal configurations are affected, but it seems to be reverted almost to the boilerplate. Only first save of every file is present. (all files seem present, but only their initial versions)

I have found more incidents like this one, but it always involved some kind of version control sync error or remote storage. This one happened on private local files as I've been using code as a simple editor. Personally, and as a developer I found this catastrophic. A program should never destroy information and even when doing it as commanded, should always ask confirmation and store backups. It's worse than disk corruption. Now I have to inspect all the files I developed with it, searching for unspected (and hidden) changes.

So be warned about Visual Studio Code, and take this as my recomendation on using anything else.

1 Like

I feel your pain. I haven't used an IDE for many many years - a good text-editor is all I need. Wheteher I'm doing HTML/CSS/JS, Python, Ruby, or some compiled language, I find that the syntax highlighting, macros, and project/file handling are more than sufficient in something like SublimeText - and it's infinitely faster and more efficient than a behemoth such as VS (which I did use for ~15 years). ST integrates well with build & deployment scripts, file transfers and source control and is easy to customise according to need/preference. It doubles as a handy scratch-pad since you don't even need to save your files to retain them between sessions. The only "problem" I have is that it's so damn useful that I invariably end up having far too many files open in it, but I guess that's what Ctrl+P is for :slight_smile:

Edit: Also, I love the MarkDown plugin for ST - it's very close to being the ideal format for READMEs and all manner of note taking (I'm an obsessive note taker and list maker). Just the right amount of formatting options and easily translated to other formats (e.g. HTML).

I did try sublimetext in the past, but could have been so much time ago and still not so developed. I'll give it a go again, thanks for the suggestion.
On Windows I pretty much used notepad++, and that is what comes to me when I try to think on sublime.

VS has so many useful features, and the latest versions are good. Many code factoring utilities. I became dependant on coding macros, and things like "sourround with" are nice when working on web pages.

The latest on my issue is that while investigating, I saw that the interested source control was "saying things" like some files had pending changes and others where untracked. (Never activated anything on that)
After more than an hour idling, some files recovered, and when I tried to diff the recovered with the lost (that where similar) the ide told me that those files where locked.
So I think it's something related with a feature vsc has that allows closing it and continue where you left it later. The same that apparently has sublimetext, if I understood.

1 Like

not funny ... :frowning: ... to avoid this kind of trouble or hard drive crashes, etc, all my dev files are in my private cloud ... backed up automatically with the ability to come back to 32 previous versions (or so ...) ...

Yes, but I have never lost any data when relying on it.

In ST you just select some text and press Alt + Shift +W ([Edit] > [Tag] > [Wrap Selection with Tag]) and type the tag you want. With ST's multi-select functionality you can even wrap multiple individual lines with the same tag (e.g. <p> tags, or <li>s) by selecting all lines and pressing Ctrl + Shift + L ([Selection] > [Split into Lines]) followed by Alt + Shift + W. Could not be easier.

If you end up doing do a lot of JavaScript in ST you may find this useful: https://github.com/pichillilorenzo/JavaScriptEnhancements

1 Like

There are millions of users of vscode, this is unlikely to be the cause. User error is most likely I'm afraid (I know, I've done it)

Tbh, my days of working on local copies without a repo are done. I too have lost work but not since using git (apart from one time back when it was new to me & I was green and stupid) so if you aren't already familiar with git, now would be a good time. If your environment permits, sync to GitHub or other external repository.

Also, I kinda lost the thread, are you using Windows 10? Have you checked if "previous versions" is available? You may have a backup.

I used to use SublimeText but stopped using it when it became slow and bloated compared to the new-kids of Atom and their ilk. Then VScode came along that built-on and developed the ideas behind Atom and it very quickly became my go-to code editor as it is fast and - generally - reliable.

VScode to me is the perfect balance between the speed of Nodepad++ (which I still use for one-off quick edits due to speed of startup - but increasingly rarely since VScode seems to be very fast to start up anyway) and the capability of an IDE.

One thing I do however, because I tend to go overboard with extensions. I install all the possible extensions I might need but then disable all but the absolutely essential for everything ones. You can enable/disable extensions by workspace so I do that and it works REALLY well. Having multiple workspaces open, each with their own settings is a massive game-changer.

I've not seen any errors that have lost me any code at all and not heard of anyone else having that issue - do you have the Issue number so I can track it? Also, do you have some odd extensions? I assume that you are using the release version and not the dev?

With my own setup on Windows 10, I occasionally see VSC start to act a bit "funny" trying to track git changes. Note that this is almost always (possibly always) with multiple workspaces open. A simple restart of the workspace puts everything back to normal. I've not even ever had any lost data with unsaved files, VSC seems to reliably retain unsaved file data and recover it when restarted. The only other issue I've had is when running a dev instance of Node-RED from within VSC - something I do often since it makes it very easy to see the log output inside your code editor. If you forget and just close VSC with it still running, you sometimes get the node-red process still running but with no UI so you have to kill it via process explorer.

Bottom line is that VSC has made me massively more productive as a casual developer and I would be extremely reluctant to give up on it.

1 Like

I am not a particular microsoft fan, but have to say that VS Code is quite a nice project and way more capable than Sublime nowadays. It took a while before they adhered to the GDPR requirements with their telemetry, but it is working nicely. I have disabled everything with "new window" as I like to work in one window, ST had similar issues.

There are several backup extensions, too late now, but perhaps for the future ?

I've gradually been getting better at using git "properly" and it is slowly becoming more second nature, do some changes and commit. And most if not all of my important code has a GitHub or Gitlab upstream repo too.

In addition, my src code folder is synchronised to a folder on my NAS.

efficient than a behemoth such as VS (which I did use for ~15 years).

Visual Studio is not the same as Visual Studio Code (not an IDE).

1 Like

I guess we all have different limits to what we're prepared to put up with...

Not that I'm surprised: Microsoft has good form in this game.

Thank you - my bad. Having taken a look at it VSCode actually seems pretty good, especially in its "non-spying" form (VSCodium). I note with surprise that Linux binaries are available. What happened to Microsoft's "Linux is evil and will give you cancer" policy?

Died a well deserved death once Balmer went and Satya arrived.

Microsoft are very active now in open source, Linux, Mac, Android and iOS.

And yet people think nothing of using Google services. As an IT Security person, I can tell you that they are much worse. Facebook worse still of course.

At least MS don't try to hide it and you can get rid of it if you really want to. I have to say that as far as I've been able to tell (and I've had some pretty close work with MS over the last few years), they really do only use the telemetry to improve the apps. But you can never be 100% certain of course. At least their business model isn't dependent on advertising income.

3 Likes

MS has seen the light I think, you can even install linux as subsystem nowadays in Windows, but their "vision" is not clear to me though.

Intel is also aiming for Linux, with their ClearLinux project quite nice and extremely fast OS, especially with python, stateless, ie. keeping the OS separated from the user, update kernel while keeping it running, no reboots.

btw you can turn off telemetry in VScode, I think it is off by default now, but used to be opt-out.

1 Like

Going off-topic somewhat but I think that Satya's vision is pretty clear. Of course, not everyone in MS shares that vision even now.

Recurring revenue through global Cloud services is what drives the financial wheels of MS now. Pretty much everything else is designed to draw you like a moth to a flame :wink: So a % of that revenue is used to develop tools and services on every possible platform so that everyone gets to experience something useful and powerful and is steered towards the Cloud services.

@tilleul @Steve-Mcl Yes, syncing to a repo is helpful, but my situation, in my homework place is exceptional. I live in the sticks, and currently my connectivity relies in a 3G connection. And it has been a huge improvement over DSL, apart from the lightning protection (I had my insurance trained in replacing devices). I could perceive when an android device was updating something and better don't talk about the new and improved microsoft update system. A 125kbps upload bandwidth would not be exagerating.
So I have a very adapted network with opnsense and custom dns resolver config, blocking unwanted traffic so I can get something more from my connection. I learned to avoid cloud services, you know.

1 Like

While I was using kubuntu, that could be. Late yesterday I was working on this solution while transferring code parts from my uibuilder dashboard and occasionally looking at an example. So there where three instances of vscode running. Now that you said, I did see the source control tab "moving" sometimes, as you said, like trying to track a ficticial repo changes.

So what repo platform you use for "private" sources? I heard something about github offering free repos, perhaps due to being adquired by MS. And that may also be the source of my problem, VSC hiddently syncing changes to a hidden github account, with me having a shitty connection. That could explain why more than an hour before I have available most of the lost code. But that's only speculation.

I don't want to (continue to) hijack the thread, but...

I really don't agree, I think they go to great lengths to hide or at least obfuscate what data you're leaking to them - as illustrated by the example in my second link.

In that case, I'm not "people".

I'm sure that must be why the T&Cs say "The data is shared among Microsoft-controlled affiliates and subsidiaries and with law enforcement"...

@clickworkorange You can easily drop that telemetry by using a custom gateway/router/resolver, like I do.
I could see huge amounts of shit in my firewall logs coming to and from my google home mini.
Also there was a time when I was so worried about big amounts of traffic (for me was huge) to and from strange CDNs, I knew the ones from microsoft, google and amazon, but alibaba?? And Romania? What I've missed there?
Well, you won't believe what Sony Bravia Tellies do while turned off. Microsoft is the small animal, as TotallyInformation said.

1 Like

Have you checked if anything could be retrieved from the local git repo. I assume you did use it locally in your workspace, I hope? :thinking:
Git does a good job of keeping dangling or loose commits around for a while, so nothing that has been part of a commit is really lost. But that may require some analysis work, I never had the need to do that.

I use Git extensively at home and at work. Everything is pushed to at least one other Linux machine via Git+SSH.