Repository: vscode
Issue: Saving ipynb file corrupts the JSON format - Unexpected end of JSON input
Labels: bug,info-needed,important,notebook-serialization

<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ -->
<!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ -->
<!-- 🕮 Read our guide about submitting issues: https://github.com/microsoft/vscode/wiki/Submitting-Bugs-and-Suggestions -->
<!-- 🔎 Search existing issues to avoid creating duplicates. -->
<!-- 🧪 Test using the latest Insiders build to see if your issue has already been fixed: https://code.visualstudio.com/insiders/ -->
<!-- 💡 Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. -->
<!-- 🔧 Launch with `code --disable-extensions` to check. -->
Hi,

I've been working with vs code via SSH for quite a few years now and encountered and new bug yesterday that makes working with .ipynb files almost impossible.

What happens is - After saving the file the JSON format is corrupted and it cannot be accessed again. I need to recreate it from scratch. 
There are some strange behaviors for this bug:
1. Often the file saving happens regardless of me saving or not.
2. Sometimes vs-code explicitly asks me if it's ok to save stating it needs to overwrite changes.
3. Looking into the JSON file with the text editor, it seems as though it simply "cuts out" the last part of the file. See example:

```
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "for epoch in range(num_epochs):\n",
    "    losses = []\n",
    "    for batch_images, batch_labels in tqdm(train_loader):\n",
    "        optimizer.zero_grad()\n",
    "        batch_images = batch_images.to(device).cuda().fl
```
*** Notice the string doesn't end properly.

I assume this has to do with the print output of the code cell (I'm using Python's tqdm library)

Does this issue occur when all extensions are disabled?: Yes/No

All extensions are active.

<!-- 🪓 If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. -->
<!-- 📣 Issues caused by an extension need to be reported directly to the extension publisher. The 'Help > Report Issue' dialog can assist with this. -->
- VS Code Version: 1.77.3
- OS Version: Linux:

NAME="CentOS Stream"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Stream 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"


Steps to Reproduce:
1. This is the cell causing the issue:

```
for epoch in range(num_epochs):
    losses = []
    for batch_images, batch_labels in tqdm(train_loader):
        optimizer.zero_grad()
        batch_images = batch_images.to(device).cuda().double().reshape(batch_images.shape[0], 3, 224, 224)
        output = model(batch_images)
        loss = nn.MSELoss()(batch_images, output)
        loss.backword()
        losses.append(loss.item())
        optimizer.step()
    if epoch % 1 == 0:
        print("Epoch [{}/{}], MSE Loss = {:.8}".format(epoch, num_epochs, np.mean(losses)))
    if epoch % 1 == 0:
        umap_validation(model, train_loader, device, epoch)
```
(Let me know if you wish me to upload the entire notebook)
2. The dataset I'm using is very large - The [COCO dataset](https://cocodataset.org/) (~18GB)