zed
zed copied to clipboard
Large files without newlines (all on one line) cause Zed to hang/crash
Summary: Opening a big JSON file without linebreaks causes Zed to freeze.
To reproduce:
- Open a big JSON file with no linebreaks, example: https://formulae.brew.sh/api/formula.jws.json
- Zed will freeze/crash.
Also reproducible with:
dd if=/dev/zero of=null-file-1mb.txt bs=1M count=1
dd if=/dev/zero of=null-file-10mb.txt bs=10M count=1
zed null-file-10mb.txt
Workaround: Format the JSON onto multiple lines
jq . filename > filename-formatted.json
Environment
Zed: v0.146.5 (Zed) OS: Linux Wayland manjaro unknown Memory: 15.3 GiB Architecture: x86_64 GPU: Intel(R) Xe Graphics (TGL GT2) || Intel open-source Mesa driver || Mesa 24.1.5-manjaro1.1
(with highlighting disabled).
Have a setting like large-file-warning-threshold in Emacs would be great. If the file is larger than the threshold, the file will be opened literally without any latency and issue.
For me Zed is able to open a 1.2GB text file without crashing, so I wonder if this is JSON specific. Does Zed still crash if you rename the file from .json to .txt?
Zed performing poorly with buffers >16M lines long is a known issue:
- https://github.com/zed-industries/zed/issues/5355
For me Zed freezes and crashes for a 166 MiB JSON file just the same regardless of the file extension, so it's not JSON specific. But all that text is on one line, so it might have something to do with that
My guess is that this is to do with line length, and (unless one already exists), I think it simply needs a cap (like VSCode's editor.stopRenderingLineAt, and potentially editor.maxTokenizationLineLength).
I have a .log (20MB) file, and around 200-300 lines down, there's a very long line (1,541,369 characters long), so as soon as I open the file it hangs and usually crashes outright (no extensions or custom settings).
I've done a couple tests in some other editors I frequently use:
- Helix Editor handles this by not rendering anything outside the visible part of the buffer (i.e., it runs fine until you reach that line and chugs along until it's back out of view).
- VSCode handles this with a default
editor.stopRenderingLineAtandeditor.maxTokenizationLineLength(and line wrapping by default). - Both NeoVim and Vim do the same as Helix, but also implement wrapping by default.
Enabling line wrapping in Zed also does not seem to help the issue.
I used jq to pre-format JSON, then I added .txt extension to prevent JSON parsing, and now I'm able to open the file in Zed.
It's not perfect though. Often Zed will crash at some point in time, and then there's the aforementioned rendering problem.
Any updates for this? Would it be possible to get a fix for this in recent upcoming releases?
Just experience this after opening a 25mb json file without linebreaks.
Environment Zed: Zed 0.205.5 – /usr/lib/zed/zed-editor OS: Archlinux Hyprland Memory: 32GB Architecture: x86_64 GPU: AMD ATI Radeon 540/540X/550/550X / RX 540X/550/550X
@mrepol742 if you'd like to provide the JSON file in question, or another anonymized JSON file that also causes a crash that would be most welcome :)
@mrepol742 if you'd like to provide the JSON file in question, or another anonymized JSON file that also causes a crash that would be most welcome :)
@probably-neb This one http://data.phishtank.com/data/online-valid.json from Phishtank that is almost 30MB