zed icon indicating copy to clipboard operation
zed copied to clipboard

Large files without newlines (all on one line) cause Zed to hang/crash

Open giovannicimolin opened this issue 1 year ago • 6 comments

Summary: Opening a big JSON file without linebreaks causes Zed to freeze.

To reproduce:

  1. Open a big JSON file with no linebreaks, example: https://formulae.brew.sh/api/formula.jws.json
  2. 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

giovannicimolin avatar Aug 12 '24 16:08 giovannicimolin

(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.

failable avatar Aug 13 '24 04:08 failable

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

notpeter avatar Aug 13 '24 18:08 notpeter

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

wlinna avatar Nov 17 '24 17:11 wlinna

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.stopRenderingLineAt and editor.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.

kanielrkirby avatar Nov 23 '24 13:11 kanielrkirby

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.

wlinna avatar Nov 24 '24 21:11 wlinna

Any updates for this? Would it be possible to get a fix for this in recent upcoming releases?

ChiragM999 avatar Apr 07 '25 17:04 ChiragM999

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 avatar Sep 26 '25 05:09 mrepol742

@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 avatar Sep 29 '25 14:09 probably-neb

@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

mrepol742 avatar Sep 30 '25 01:09 mrepol742