Skip to content

fix(windows): use vim.json.decode to avoid E5560 in fast-event context - #327

Merged
nickjvandyke merged 1 commit into
nickjvandyke:mainfrom
vad-bond:fix/windows-json-decode-fast-event
Sep 14, 2026
Merged

nickjvandyke merged 1 commit into
nickjvandyke:mainfrom
vad-bond:fix/windows-json-decode-fast-event

Conversation

@vad-bond

@vad-bond vad-bond commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Tasks

  • I read CONTRIBUTING.md
  • I ensured my changes pass automated checks
  • I reviewed and understand the AI-generated code in my changes (if any)

Description

On Windows, server discovery sometimes surfaced E5560: Vimscript function "json_decode" must not be called in a fast event context, which the surrounding pcall mislabeled as a JSON parse failure.

vim.fn.json_decode is a Vimscript function call, which Neovim forbids from the fast-event context used by the vim.uv timer/job callback during Windows process discovery. This PR replaces it with vim.json.decode, which is Lua-native, API-equivalent for this use, and callable from fast-event context — so the E5560 error no longer occurs and parsing behavior is unchanged.

Testing

  1. On Windows, start an OpenCode server externally, then trigger opencode.nvim's server discovery.
  2. Before this fix: an E5560 notification appears instead of the process being discovered.
  3. After this fix: discovery succeeds silently; vim.json.decode parses the PowerShell JSON output identically to vim.fn.json_decode (single-object and array forms).

Related Issue(s)

N/A

Screenshots/Videos

N/A

vim.fn.json_decode is a Vimscript function call, which Neovim forbids
from fast-event contexts such as the vim.uv timer/job callback used
during Windows server discovery. This raised E5560, which the
surrounding pcall then mislabeled as a JSON parse failure.

vim.json.decode is Lua-native and callable from fast-event context,
and is API-equivalent for this use, so parsing behavior is unchanged.
@vad-bond
vad-bond force-pushed the fix/windows-json-decode-fast-event branch from 5ff5038 to 71c22b4 Compare September 12, 2026 08:22
@nickjvandyke

Copy link
Copy Markdown
Owner

Good find, thank you!

@nickjvandyke
nickjvandyke merged commit 618c91a into nickjvandyke:main Sep 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants