Skip to content

Conversation

@tjg184
Copy link
Contributor

@tjg184 tjg184 commented Jan 5, 2026

This is a proposal to allow timeouts to be set for LSPs at the specific server/LSP levels. Currently, there is a default timeout of 45 seconds, which is sometimes not long enough. As one example, in the kotlin-ls LSP, some projects are larger and could take longer than this to initialize.

This PR is attempting to allow a specific server timeout only.

An example is below showing overriding the kotlin-ls timeout.

{
  "$schema": "https://opencode.ai/config.json",
  "instructions": ["STYLE_GUIDE.md"],
  "provider": {
    "opencode": {
      "options": {},
    },
  },
  "lsp": {
    "kotlin-ls": {
      "timeout": 120000, 
    },
  },
}

@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

The following comment was made by an LLM, it may be inaccurate:

Results:

No duplicate PRs found. The search for "lsp timeout" and "configurable timeout" returned PR #6997 (the current PR) along with some tangentially related PRs, but none of them appear to be addressing the same feature:

Conclusion: PR #6997 appears to be a unique feature request for configurable LSP timeout with no existing duplicates.

@tjg184 tjg184 force-pushed the lsp_timeout branch 8 times, most recently from 2f8d58a to 2e64e7a Compare January 5, 2026 23:51
@tjg184 tjg184 marked this pull request as ready for review January 5, 2026 23:58
@rekram1-node
Copy link
Collaborator

Adding timeout field to this makes sense:

      lsp: z
        .union([
          z.literal(false),
          z.record(
            z.string(),
            z.union([
              z.object({
                disabled: z.literal(true),
              }),
              z.object({
                command: z.array(z.string()),
                extensions: z.array(z.string()).optional(),
                disabled: z.boolean().optional(),
                env: z.record(z.string(), z.string()).optional(),
                initialization: z.record(z.string(), z.any()).optional(),
                timeout: .... // <<<<<<<<<<<<<<<<<< THIS HERE
              }),
            ]),
          ),
        ])

I dont really like that global version you did, I'd rather just make a flag

@tjg184
Copy link
Contributor Author

tjg184 commented Jan 6, 2026

Adding timeout field to this makes sense:

      lsp: z
        .union([
          z.literal(false),
          z.record(
            z.string(),
            z.union([
              z.object({
                disabled: z.literal(true),
              }),
              z.object({
                command: z.array(z.string()),
                extensions: z.array(z.string()).optional(),
                disabled: z.boolean().optional(),
                env: z.record(z.string(), z.string()).optional(),
                initialization: z.record(z.string(), z.any()).optional(),
                timeout: .... // <<<<<<<<<<<<<<<<<< THIS HERE
              }),
            ]),
          ),
        ])

I dont really like that global version you did, I'd rather just make a flag

Good call on removing the global timeout. Take a look at the change now. It's slightly different than what you suggested, as I believe just adding the timeout field would not allow someone to override a built-in server without specifying a command. With the proposed changes, it would allow a timeout to override a built-in server, along with a timeout for a custom server too. I tried to cover this with tests. The only thing I don't like is that the command is now optional (and I believe it has to be) since someone could just specify a timeout. I tried to catch this in the refine rules.

Comment on lines 907 to 911
z.union([
z.object({
disabled: z.literal(true),
}),
z.object({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did we get rid of the union here? That union made some of the code nicer, now u need extra null checks everywhere...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that was a mistake. I corrected it.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@tjg184 tjg184 requested a review from rekram1-node January 9, 2026 00:41
@tjg184 tjg184 marked this pull request as draft January 9, 2026 11:59
@tjg184 tjg184 marked this pull request as ready for review January 9, 2026 12:01
@tjg184 tjg184 marked this pull request as draft January 9, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants