zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
50.31k stars 3.1k forks source link

Formatting large JSON files results in timeout #10122

Open imraan-go opened 7 months ago

imraan-go commented 7 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

  1. Open the attached JSON file
  2. Try to format it with "CTRL+SHIFT+P" > Editor:Format
  3. Nothing happens. Zed logs message timed out waiting for formatting

0facf541-2f9b-4cdb-b5c5-8fd4e35eb7a2.1.json

Environment

Zed: v0.128.3 (Zed) OS: macOS 14.4.1 Memory: 32 GiB Architecture: aarch64

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

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

2024-04-03T06:42:37-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:42:37-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:42:44-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:42:48-07:00 [WARN] timed out waiting for formatting 2024-04-03T06:42:49-07:00 [WARN] failed to deserialize LSP message: {"jsonrpc":"2.0","error":{"code":-32600,"message":"error during message '{\"jsonrpc\":\"2.0\",\"method\":\"$/cancelRequest\",\"params\":{\"id\":9}}' handling: Error: Message id is undefined: {\"jsonrpc\":\"2.0\",\"method\":\"$/cancelRequest\",\"params\":{\"id\":9}}"}} 2024-04-03T06:43:01-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:43:01-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:43:01-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:45:26-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:45:30-07:00 [WARN] timed out waiting for formatting 2024-04-03T06:45:31-07:00 [WARN] failed to deserialize LSP message: {"jsonrpc":"2.0","error":{"code":-32600,"message":"error during message '{\"jsonrpc\":\"2.0\",\"method\":\"$/cancelRequest\",\"params\":{\"id\":10}}' handling: Error: Message id is undefined: {\"jsonrpc\":\"2.0\",\"method\":\"$/cancelRequest\",\"params\":{\"id\":10}}"}} 2024-04-03T06:46:13-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:13-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:13-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:13-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:13-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:13-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:13-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:13-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:13-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:13-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:13-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:13-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:13-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:14-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:14-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:14-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:14-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:14-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:14-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:14-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:14-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:14-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:14-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:14-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition 2024-04-03T06:46:16-07:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition

failable commented 6 months ago

Also happen for 'large' Python file.

dsizer commented 6 months ago

Here to echo - I am hitting this same error when trying to format a large Python file with the black external formatter.

To me it seems like the solution is just to make the formatting timeout configurable in settings.json? Not sure if I should open a separate issue for that

RhetTbull commented 6 months ago

The same thing happens to me with large python files using black. In my case I actually call the following script as external editor. This works fine for small python files but times out on large files. If we could configure the timeout that would be very helpful. "Large" in my case is anything above ~1500 lines.

#!/bin/bash

# run isort then black on stdin and write to stdout
# for use with zed external formatter

isort - | black -
fauh45 commented 4 months ago

Same thing happened to me too by using djlint as an external formatter. I think timeout should just be able to be set as a setting

WSSDude commented 3 months ago

Same exact issue...

2024-07-26T12:41:37.800467792+02:00 [WARN] timed out waiting for formatting

I get this in the log when I try to format large document and it does not format it. Is super annoying.

jswny commented 2 months ago

Running into this as well. This is pretty important since I use my text editor all the time to format large JSON files and I cannot do so in Zed since the formatter always times out.

marvin-yorke commented 2 months ago

Can we please at least have a timeout configuration option in settings? It's very frustrating, especially since some files format ok, while others just do nothing, not even indicating an error. It took me a while to figure out to check the log file for errors

ifsheldon commented 3 days ago

Running into this as well. My JSON file is ~2MB, which after formatting is 28K lines. With the default formatter, Zed took like a minute to try to format it and failed because of timeout. But Rustrover happily formatted it in ~3 seconds.

The performance gap is unbelievable. I'd really like to contribute on this issue, but I need a pointer into the code.