github / github/copilot-language-server-release

MaxListenersExceededWarning: Possible EventEmitter memory leak detected in copilot-language-server

Open
#25 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
290
Forks
24
PR merge metrics
No merged PRs in 30d

Description

## Background

Since switching our copilot integration from using non-incremental updating (sending the entire document with each `textDocument/didChange` and keeping the version at 0) to incremental, I'm seeing the following error (doesn't always repro, feels like there's a timing issue involved). Not noticing any user impact, but wondering if I'm doing something wrong in my calling pattern to cause this.

> (node:4231) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 change listeners added to [EventEmitter]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit
(Use `copilot-language-server --trace-warnings ...` to show where the warning was created)

## RPC calls

Here are the messages involved in my most recent repro attempt (I've left out `statusNotification`, `didChangeStatus`, `preconditionsNotification`, and `featureFlagsNotification` messages as they seem ignorable in this context).

The document started in this state:

Image

Final state:

Image

### initialize (call)

```json
{"jsonrpc":"2.0","method":"initialize","params":{"processId":4218,"locale":"en","initializationOptions":{"editorInfo":{"name":"RStudio","version":"2025.06.999-dev+999"},"editorPluginInfo":{"name":"RStudio","version":"2025.06.999-dev+999"}},"capabilities":{"workspace":{"workspaceFolders":false}}},"id":"ca2a707b-e2c9-4e8d-959f-04e91bd9a9ef"}
```

### initialize (response)

```json
{"jsonrpc":"2.0","id":"ca2a707b-e2c9-4e8d-959f-04e91bd9a9ef","result":{"capabilities":{"textDocumentSync":{"openClose":true,"change":2},"notebookDocumentSync":{"notebookSelector":[{"notebook":"*"}]},"workspace":{"workspaceFolders":{"supported":false,"changeNotifications":false}},"executeCommandProvider":{"commands":["github.copilot.finishDeviceFlow","github.copilot.didAcceptCompletionItem","github.copilot.didAcceptNextEditSuggestionItem","github.copilot.didAcceptPanelCompletionItem"]},"inlineCompletionProvider":{}},"serverInfo":{"name":"GitHub Copilot Language Server","version":"1.335.0","nodeVersion":"20.18.2"}}}
```

### initialized (call)

```json
{"jsonrpc":"2.0","method":"initialized","params":{}}
```

### didChangeConfiguration (call)

```json
{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{}}}
```

### logMessage (notification)

```json
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[lsp] GitHub Copilot Language Server 1.335.0 initialized"}}
```

### logMessage (notification)

```json
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[certificates] Removed 3 expired certificates"}}
```

### didFocus (call)

```json
{"jsonrpc":"2.0","method":"textDocument/didFocus","params":{"textDocument":{"uri":"file:///Users/gary/aaa/aaa/a.R"}}}
```

### didOpen (call)

```json
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///Users/gary/aaa/aaa/a.R","languageId":"r","version":0,"text":"\na <- 5\nb <- a\nc <- 6\n\n# this is a comment\n"}}}
```

### inlineCompletion (call)

```json
{"jsonrpc":"2.0","method":"textDocument/inlineCompletion","params":{"textDocument":{"uri":"file:///Users/gary/aaa/aaa/a.R","version":0},"position":{"line":6,"character":0},"context":{"triggerKind":2}},"id":"eddc0b88-a571-4714-8675-a789bf28537b"}
```

### logMessage (notification)

```json
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[default] Context provider relatedFilesShim exceeded time budget of 150ms"}}
```

### logMessage (notification)

```json
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[fetchCompletions] Request 0d617a2f-ade8-4171-92f0-1eff00770737 at finished with 200 status after 772.2371669999998ms"}}
```

### logMessage (notification)

```json
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[streamChoices] solution 0 returned. finish reason: [stop]"}}
```

### inlineCompletion (response)

```json
{"jsonrpc":"2.0","id":"eddc0b88-a571-4714-8675-a789bf28537b","result":{"items":[{"command":{"title":"Completion Accepted","command":"github.copilot.didAcceptCompletionItem","arguments":["027f8cfb-bd81-4aa4-a530-be2ff5b823d0"]},"insertText":"d <- b + c","range":{"start":{"line":6,"character":0},"end":{"line":6,"character":0}}}]}}
```

### didShowCompletion (call)

```json
{"jsonrpc":"2.0","method":"textDocument/didShowCompletion","params":{"item":{"command":{"title":"Completion Accepted","command":"github.copilot.didAcceptCompletionItem","arguments":["027f8cfb-bd81-4aa4-a530-be2ff5b823d0"]},"insertText":"d <- b + c","range":{"start":{"line":6,"character":0},"end":{"line":6,"character":0}}}}}
```

### didFocus (call)

```json
{"jsonrpc":"2.0","method":"textDocument/didFocus","params":{"textDocument":{"uri":"file:///Users/gary/aaa/aaa/a.R"}}}
```

### executeCommand (call -- accepted completion)

```json
{"jsonrpc":"2.0","method":"workspace/executeCommand","params":{"title":"Completion Accepted","command":"github.copilot.didAcceptCompletionItem","arguments":["027f8cfb-bd81-4aa4-a530-be2ff5b823d0"]}}
```

### didChange (call)

```json
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///Users/gary/aaa/aaa/a.R","languageId":"r","version":1},"contentChanges":[{"range":{"start":{"line":6,"character":0},"end":{"line":6,"character":0}},"text":"d <- b + c\n"}]}}
```

### inlineCompletion (call)

```json
{"jsonrpc":"2.0","method":"textDocument/inlineCompletion","params":{"textDocument":{"uri":"file:///Users/gary/aaa/aaa/a.R","version":1},"position":{"line":7,"character":0},"context":{"triggerKind":2}},"id":"688ea3f7-b00e-488f-bd91-d980354ac3e0"}
```

### logMessage (notification)

```json
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[fetchCompletions] Request 7aa36d44-e14a-4f67-bbb8-640b6d69b373 at finished with 200 status after 386.9849579999991ms"}}
```

### logMessage (notification)

```json
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[streamChoices] solution 0 returned. finish reason: [stop]"}}
```

### inlineCompletion (response)

```json
{"jsonrpc":"2.0","id":"688ea3f7-b00e-488f-bd91-d980354ac3e0","result":{"items":[{"command":{"title":"Completion Accepted","command":"github.copilot.didAcceptCompletionItem","arguments":["1a6aece6-9d05-4ccf-9d55-ce4ec3b9b6d6"]},"insertText":"# this is another comment","range":{"start":{"line":7,"character":0},"end":{"line":7,"character":0}}}]}}
```

### didShowCompletion (call)

```json
{"jsonrpc":"2.0","method":"textDocument/didShowCompletion","params":{"item":{"command":{"title":"Completion Accepted","command":"github.copilot.didAcceptCompletionItem","arguments":["1a6aece6-9d05-4ccf-9d55-ce4ec3b9b6d6"]},"insertText":"# this is another comment","range":{"start":{"line":7,"character":0},"end":{"line":7,"character":0}}}}}
```

### didChange (call)

```json
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///Users/gary/aaa/aaa/a.R","languageId":"r","version":2},"contentChanges":[{"range":{"start":{"line":7,"character":0},"end":{"line":7,"character":0}},"text":"\n"}]}}
```

### inlineCompletion (call)

```json
{"jsonrpc":"2.0","method":"textDocument/inlineCompletion","params":{"textDocument":{"uri":"file:///Users/gary/aaa/aaa/a.R","version":2},"position":{"line":8,"character":0},"context":{"triggerKind":2}},"id":"55bc2bd3-c2bd-4333-be54-9b6e5cd95dc4"}
```

### logMessage (notification)

```json
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[fetchCompletions] Request b3c77ec7-673d-4fb7-b898-d851a4fd9577 at finished with 200 status after 420.9779579999995ms"}}
```

### logMessage (notification)

```json
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[streamChoices] solution 0 returned. finish reason: [stop]"}}
```

### inlineCompletion (response)

```json
{"jsonrpc":"2.0","id":"55bc2bd3-c2bd-4333-be54-9b6e5cd95dc4","result":{"items":[{"command":{"title":"Completion Accepted","command":"github.copilot.didAcceptCompletionItem","arguments":["192b74e7-f239-47a7-839e-74ca56bb4fca"]},"insertText":"# this is another comment","range":{"start":{"line":8,"character":0},"end":{"line":8,"character":0}}}]}}
```

### didShowCompletion (call)

```json
{"jsonrpc":"2.0","method":"textDocument/didShowCompletion","params":{"item":{"command":{"title":"Completion Accepted","command":"github.copilot.didAcceptCompletionItem","arguments":["192b74e7-f239-47a7-839e-74ca56bb4fca"]},"insertText":"# this is another comment","range":{"start":{"line":8,"character":0},"end":{"line":8,"character":0}}}}}
```

### executeCommand (call -- accepted completion)

```json
{"jsonrpc":"2.0","method":"workspace/executeCommand","params":{"title":"Completion Accepted","command":"github.copilot.didAcceptCompletionItem","arguments":["192b74e7-f239-47a7-839e-74ca56bb4fca"]}}
```

### didChange (call)

```json
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///Users/gary/aaa/aaa/a.R","languageId":"r","version":3},"contentChanges":[{"range":{"start":{"line":8,"character":0},"end":{"line":8,"character":0}},"text":"# this is another comment"}]}}
```

### inlineCompletion (call)

```json
{"jsonrpc":"2.0","method":"textDocument/inlineCompletion","params":{"textDocument":{"uri":"file:///Users/gary/aaa/aaa/a.R","version":3},"position":{"line":8,"character":25},"context":{"triggerKind":2}},"id":"e75d818e-4ecd-48fa-960b-4570c77674a9"}
```

### logMessage (notification)

```json
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[fetchCompletions] Request d30dc207-9119-49d5-94f4-77630cc21038 at finished with 200 status after 179.9752499999995ms"}}
```

### logMessage (notification)

```json
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[streamChoices] solution 0 returned. finish reason: [stop]"}}
```

### inlineCompletion (response)

```json
{"jsonrpc":"2.0","id":"e75d818e-4ecd-48fa-960b-4570c77674a9","result":{"items":[]}}
```

### didChange (call)

```json
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///Users/gary/aaa/aaa/a.R","languageId":"r","version":4},"contentChanges":[{"range":{"start":{"line":8,"character":25},"end":{"line":8,"character":25}},"text":"\n"}]}}
```

### inlineCompletion (call)

```json
{"jsonrpc":"2.0","method":"textDocument/inlineCompletion","params":{"textDocument":{"uri":"file:///Users/gary/aaa/aaa/a.R","version":4},"position":{"line":9,"character":0},"context":{"triggerKind":2}},"id":"3272b1b2-c5a8-407b-86ee-2dee3d9f8241"}
```

### logMessage (notification)

```json
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[fetchCompletions] Request bb7d86a2-fdab-4cb1-b0bc-a50e257da4d3 at finished with 200 status after 261.87508399999933ms"}}
```

### logMessage (notification)

```json
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[streamChoices] solution 0 returned. finish reason: [stop]"}}
```

### inlineCompletion (response)

```json
{"jsonrpc":"2.0","id":"3272b1b2-c5a8-407b-86ee-2dee3d9f8241","result":{"items":[{"command":{"title":"Completion Accepted","command":"github.copilot.didAcceptCompletionItem","arguments":["5c6a8018-2378-4690-a859-4ecb00575201"]},"insertText":"e <- d + 1","range":{"start":{"line":9,"character":0},"end":{"line":9,"character":0}}}]}}
```

### didShowCompletion (call)

```json
{"jsonrpc":"2.0","method":"textDocument/didShowCompletion","params":{"item":{"command":{"title":"Completion Accepted","command":"github.copilot.didAcceptCompletionItem","arguments":["5c6a8018-2378-4690-a859-4ecb00575201"]},"insertText":"e <- d + 1","range":{"start":{"line":9,"character":0},"end":{"line":9,"character":0}}}}}
```

### executeCommand (call -- accepted completion)

```json
{"jsonrpc":"2.0","method":"workspace/executeCommand","params":{"title":"Completion Accepted","command":"github.copilot.didAcceptCompletionItem","arguments":["5c6a8018-2378-4690-a859-4ecb00575201"]}}
```

### didChange (call)

```json
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///Users/gary/aaa/aaa/a.R","languageId":"r","version":5},"contentChanges":[{"range":{"start":{"line":9,"character":0},"end":{"line":9,"character":0}},"text":"e <- d + 1"}]}}
```

### inlineCompletion (call)

```json
{"jsonrpc":"2.0","method":"textDocument/inlineCompletion","params":{"textDocument":{"uri":"file:///Users/gary/aaa/aaa/a.R","version":5},"position":{"line":9,"character":10},"context":{"triggerKind":2}},"id":"5a24dd9f-1537-4588-ba0c-cb8ee9c9255c"}
```

### logMessage (notification)

```json
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[fetchCompletions] Request a37a6e57-16e7-4cae-95d5-7223d7b57233 at finished with 200 status after 263.04254200000105ms"}}
```

### logMessage (notification)

```json
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[streamChoices] solution 0 returned. finish reason: [stop]"}}
```

### inlineCompletion (response)

```json
{"jsonrpc":"2.0","id":"5a24dd9f-1537-4588-ba0c-cb8ee9c9255c","result":{"items":[]}}
```

### didChange (call)

```json
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///Users/gary/aaa/aaa/a.R","languageId":"r","version":6},"contentChanges":[{"range":{"start":{"line":9,"character":10},"end":{"line":9,"character":10}},"text":"\n"}]}}
```

### inlineCompletion (call)

```json
{"jsonrpc":"2.0","method":"textDocument/inlineCompletion","params":{"textDocument":{"uri":"file:///Users/gary/aaa/aaa/a.R","version":6},"position":{"line":10,"character":0},"context":{"triggerKind":2}},"id":"00566178-61ca-4957-9a26-00ff04e8921d"}
```

### logMessage (notification)

```json
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[fetchCompletions] Request 03b5aa8c-5f6c-4229-8457-2ff872ef0142 at finished with 200 status after 365.898459ms"}}
```

### logMessage (notification)

```json
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[streamChoices] solution 0 returned. finish reason: [stop]"}}
```

### inlineCompletion (response)

```json
{"jsonrpc":"2.0","id":"00566178-61ca-4957-9a26-00ff04e8921d","result":{"items":[{"command":{"title":"Completion Accepted","command":"github.copilot.didAcceptCompletionItem","arguments":["c389786a-5015-4cae-b3d2-cd93036f494b"]},"insertText":"# this is a third comment","range":{"start":{"line":10,"character":0},"end":{"line":10,"character":0}}}]}}
```

### didShowCompletion (call)

```json
{"jsonrpc":"2.0","method":"textDocument/didShowCompletion","params":{"item":{"command":{"title":"Completion Accepted","command":"github.copilot.didAcceptCompletionItem","arguments":["c389786a-5015-4cae-b3d2-cd93036f494b"]},"insertText":"# this is a third comment","range":{"start":{"line":10,"character":0},"end":{"line":10,"character":0}}}}}
```

### didChange (call)

```json
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///Users/gary/aaa/aaa/a.R","languageId":"r","version":7},"contentChanges":[{"range":{"start":{"line":10,"character":0},"end":{"line":10,"character":0}},"text":"\n"}]}}
```

### inlineCompletion (call)

```json
{"jsonrpc":"2.0","method":"textDocument/inlineCompletion","params":{"textDocument":{"uri":"file:///Users/gary/aaa/aaa/a.R","version":7},"position":{"line":11,"character":0},"context":{"triggerKind":2}},"id":"2b090533-d462-4bd0-b62b-57d2979e9dc7"}
```

### logMessage (notification)

```json
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[fetchCompletions] Request 3d022adc-effa-4b2a-bcd0-339a7e96f5fa at finished with 200 status after 374.5305420000004ms"}}
```

### logMessage (notification)

```json
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[streamChoices] solution 0 returned. finish reason: [stop]"}}
```

### inlineCompletion (response)

```json
{"jsonrpc":"2.0","id":"2b090533-d462-4bd0-b62b-57d2979e9dc7","result":{"items":[{"command":{"title":"Completion Accepted","command":"github.copilot.didAcceptCompletionItem","arguments":["bb922201-3132-4a38-83a7-e935fdc1f032"]},"insertText":"f <- e + 2","range":{"start":{"line":11,"character":0},"end":{"line":11,"character":0}}}]}}
```

```
(node:4231) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 change listeners added to [EventEmitter]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit
(Use `copilot-language-server --trace-warnings ...` to show where the warning was created)
```

### didShowCompletion (call)

```json
{"jsonrpc":"2.0","method":"textDocument/didShowCompletion","params":{"item":{"command":{"title":"Completion Accepted","command":"github.copilot.didAcceptCompletionItem","arguments":["bb922201-3132-4a38-83a7-e935fdc1f032"]},"insertText":"f <- e + 2","range":{"start":{"line":11,"character":0},"end":{"line":11,"character":0}}}}}
```

Contributor guide

Open the contributing guide

Research direction

Start with the reported Node.js MaxListenersExceededWarning and the incremental textDocument/didChange sequence in the issue. Reproduce the sequence around didFocus, didOpen, inlineCompletion, didShowCompletion, and accepted completions, using --trace-warnings as suggested. Done means determining whether the calling pattern causes the warning and documenting an actionable cause or fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.