Skip to content

Crash if LSP settings missing enableDiagnostics key #1869

@notpeter

Description

@notpeter

Bug description

Since #1828 (@prisma/language-server >= "6.8.0") prisma-language-server crashes on startup with an empty settings -- or more specifically, any settings which does not provide enableDiagnostics.

How to reproduce

Steps to reproduce the behavior:

  1. Launch Zed
  2. Install Zed Prisma extension v0.1.0
  3. Open a .prisma file
  4. From the command palette (cmd-shift-p) spawn dev: language server logs
  5. Select 'prisma-language-server' from the dropdown
  6. In the server-logs, note:
Default version of Prisma 'prisma-schema-wasm': 2060c79ba17c6bb9f5823312b6f6b7f4a845738e
Extension name @prisma/language-server with version 6.8.2
Prisma Engines version: 6.8.0-43.2060c79ba17c6bb9f5823312b6f6b7f4a845738e
Prisma CLI version: 6.8.2
Configuration changed.
/Users/peter/Library/Application Support/Zed/extensions/work/prisma/node_modules/@prisma/language-server/dist/server.js:151
        if (settings.enableDiagnostics === false) {
                     ^

TypeError: Cannot read properties of null (reading 'enableDiagnostics')
    at validateTextDocument (/Users/peter/Library/Application Support/Zed/extensions/work/prisma/node_modules/@prisma/language-server/dist/server.js:151:22)
    at async /Users/peter/Library/Application Support/Zed/extensions/work/prisma/node_modules/@prisma/language-server/dist/server.js:162:9

Node.js v23.11.0

Workaround is to explicitly provide "enableDiagnostics": true via LSP settings.

Expected behavior

prisma-language-server does not crash with empty settings.

Prisma information

if (settings.enableDiagnostics === false) {
await connection.sendDiagnostics({ uri: textDocument.uri, diagnostics: [] })
return
}

Environment & setup

  • OS: macOS
  • Editor: Zed
  • Editor version: v0.189.x nightly, Prisma extension v0.1.0.
  • @prisma/language-server: "6.8.2"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.topic: editorsEditors other than VS Codetopic: language server

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions