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

Zed is caching files? #20872

Open
1 task done
shinebayar-g opened this issue Nov 19, 2024 · 5 comments
Open
1 task done

Zed is caching files? #20872

shinebayar-g opened this issue Nov 19, 2024 · 5 comments
Labels
bug [core label] editor Feedback for code editing, formatting, editor iterations, etc needs info / awaiting response Issue that needs more information from the user

Comments

@shinebayar-g
Copy link

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

I'm using VSCode & Zed at the same time. Testing it hand by hand. It seems Zed is caching files aggressively.

  1. Open the same file foo.json in both VSCode and Zed at the same time.
  2. Edit the file in VSCode.
  3. Zed doesn't see the change. Usually it sees the change without even closing the active editor tab. But this time it doesn't.
  4. I even tried closing the active editor tab and re-opened the same file from the file tree. But Zed still doesn't see the change.
  5. The only way to see the change was to reload the Zed or restart Zed.

It's not reproducible in small files. The file I was working on was 30MB big json file. So I'm assuming file size may has something to do with it.

Environment

Zed: v0.162.2 (Zed Preview)
OS: macOS 15.1.0
Memory: 16 GiB
Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your Zed.log file to this issue.

Zed.log

@shinebayar-g shinebayar-g added admin read Pending admin review bug [core label] triage Maintainer needs to classify the issue labels Nov 19, 2024
@jknlsn
Copy link

jknlsn commented Nov 20, 2024

Seeing the same behaviour, in a .json file just over 2MB

@notpeter
Copy link
Member

notpeter commented Dec 3, 2024

Can you provide explicit steps to reproduce? Are you saving the file in VSCode?
When I save changes to a big JSON file in VSCode Zed immediately picks up the changes.

@shinebayar-g
Copy link
Author

Sure, I'll try to prepare exact steps to reproduce with sample data.

@jknlsn
Copy link

jknlsn commented Dec 3, 2024

In my case it was a separate script modifying the JSON, that I had open in Zed to monitor/change manually if needed.

I've just tried to write a simple script now to simulate this, but I'm not able to reproduce the exact behaviour, I'm not seeing it currently. The file is similar in size by making a minimum 3000 entries. Ramping the number up to 30000 entries doesn't seem to make a difference.
I don't know if it was to do with any other apps I had open etc, memory pressure, or version of Zed.

Anyway here's the script to give you an idea, just in case it's a starting point.

import json
import random
import string
from pathlib import Path

FIRST_NAMES = ['Emma', 'Liam', 'Olivia', 'Noah', 'Ava', 'Ethan', 'Sophia', 'Mason', 'Isabella', 'William']
LAST_NAMES = ['Smith', 'Johnson', 'Williams', 'Brown', 'Jones', 'Garcia', 'Miller', 'Davis', 'Rodriguez', 'Martinez']
DEPARTMENTS = ['science', 'math', 'history', 'english', 'art']

def generate_random_id():
    return f"{random.choice(DEPARTMENTS)}_{random.choice(LAST_NAMES).lower()}_{random.randint(1000, 9999)}"

def generate_entry():
    first_name = random.choice(FIRST_NAMES)
    last_name = random.choice(LAST_NAMES)
    dept = random.choice(DEPARTMENTS)

    return {
        "name": f"{first_name} {last_name}",
        "class": dept,
        "email": f"{first_name.lower()}.{last_name.lower()}@school.edu",
        "group": f"group_{random.randint(1, 5)}",
        "status": random.choice(['active', 'inactive', 'pending'])
    }

def generate_test_data(filename='test_data.json'):
    data = {}

    if Path(filename).exists():
        with open(filename, 'r') as f:
            data = json.load(f)

    current_count = len(data)
    if current_count < 3000:
        entries_to_add = 3000 - current_count
    else:
        entries_to_add = random.randint(5, 25)
    for _ in range(entries_to_add):
        student_id = generate_random_id()
        while student_id in data:  # Ensure unique ID
            student_id = generate_random_id()
        data[student_id] = generate_entry()

    with open(filename, 'w') as f:
        json.dump(data, f, indent=2)

    return len(data)

if __name__ == "__main__":
    final_count = generate_test_data()
    print(f"Test data generated. Total entries: {final_count}")

@notpeter notpeter added needs info / awaiting response Issue that needs more information from the user editor Feedback for code editing, formatting, editor iterations, etc and removed triage Maintainer needs to classify the issue admin read Pending admin review labels Dec 3, 2024
@notpeter
Copy link
Member

notpeter commented Dec 3, 2024

If you manage to trigger this behavior again, please see if there's anything of note in the Zed logs.

Pure speculation, but I wonder if there's a race condition where Zed gets notified of a change but before we can read the filename is replaced again. As a result Zed falls into an error state when it stops watching. (pure speculation). I'd be curious whether closing and reopning the tab (cmd-w, cmd-shift-t) brings things back to normal.

Anyways, would love something reproducible so we can dig deeper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [core label] editor Feedback for code editing, formatting, editor iterations, etc needs info / awaiting response Issue that needs more information from the user
Projects
None yet
Development

No branches or pull requests

3 participants