Skip to main content

lsp-custom-requests

Serialize URIs correctly across LSP custom requests. Use when defining custom LSP requests/notifications with URI params, sending a `URI` over `Connection.sendRequest`, or debugging `[object Object]` / `EntryNotFound` / `workspace/stat`/`readFile`/`readDirectory` failures.

Jump to install

Source facts

Repository
forcedotcom/salesforcedx-vscode
Last source activity
July 29, 2026 at 15:35
Detected SKILL.md language
English
Stars
1,034
Forks
454

Install options

The review-first prompt is selected by default. You can switch to a direct command or download a local copy.

Review the source files

Read SKILL.md and any companion files shown by SkillsMP before deciding whether to install.

Showing SKILL.md

SKILL.md
Source instructions ยท Read-only preview
name
lsp-custom-requests
description
Serialize URIs correctly across LSP custom requests. Use when defining custom LSP requests/notifications with URI params, sending a `URI` over `Connection.sendRequest`, or debugging `[object Object]` / `EntryNotFound` / `workspace/stat`/`readFile`/`readDirectory` failures.
review
never
# LSP Custom Requests โ€” URI Wire Format ## Why it breaks - `Connection.sendRequest(method, params)` runs `JSON.stringify(params)`. - `vscode-uri` `Uri.toJSON()` returns `UriComponents` (plain data). See [microsoft/vscode-uri src/uri.ts](https://github.com/microsoft/vscode-uri/blob/main/src/uri.ts). - Receiver gets a plain object โ€” no prototype, no `toString`/`fsPath`. - `uri.toString()` โ†’ `"[object Object]"` โ†’ `fs.stat`/`readFile` fails with `EntryNotFound`. ## Rules - Never call `.toString()` / `.fsPath` on a URI received over the wire without rehydrating first. - Type URI params as `UriComponents` (derived); revive on receive. ## Pattern โ€” UriComponents + revive Params type derived from `URI.toJSON`: ```ts import type { URI } from 'vscode-uri'; type UriComponents = ReturnType<URI['toJSON']>; type MyParams = { uri: UriComponents }; const params: MyParams = { uri: URI.parse(fileUri) }; connection.sendRequest('my/request', params); const handler = (params: MyParams) => { const uri = URI.revive(params.uri); }; ``` Notes: - `vscode-uri`'s package entry does not re-export `UriComponents`; derive via `ReturnType<URI['toJSON']>`. - `URI.revive` is the exact inverse of `toJSON` โ€” restores `_formatted` / `_fsPath` caches too. ## Don't - `uri: URI` on a wire type and use `.toString()` / `.fsPath` on receive โ€” this is the failure mode. - Pass deserialized params straight to `vscode.workspace.fs.*` โ€” those APIs expect a real `URI` instance. ## When `uri: URI` in params looks fine but isn't Compiles cleanly (URI on both sides). Runtime receiver sees a plain `UriComponents`. Check the handler log โ€” `uri=[object Object]` confirms.
View on GitHub