Skip to content

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

Open
@gtritchie

Description

@gtritchie

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)

{"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)

{"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)

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

didChangeConfiguration (call)

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

logMessage (notification)

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

logMessage (notification)

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

didFocus (call)

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

didOpen (call)

{"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)

{"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)

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

logMessage (notification)

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[fetchCompletions] Request 0d617a2f-ade8-4171-92f0-1eff00770737 at <https://proxy.business.githubcopilot.com/v1/engines/gpt-4o-copilot/completions> finished with 200 status after 772.2371669999998ms"}}

logMessage (notification)

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

inlineCompletion (response)

{"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)

{"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)

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

executeCommand (call -- accepted completion)

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

didChange (call)

{"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)

{"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)

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[fetchCompletions] Request 7aa36d44-e14a-4f67-bbb8-640b6d69b373 at <https://proxy.business.githubcopilot.com/v1/engines/gpt-4o-copilot/completions> finished with 200 status after 386.9849579999991ms"}}

logMessage (notification)

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

inlineCompletion (response)

{"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)

{"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)

{"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)

{"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)

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[fetchCompletions] Request b3c77ec7-673d-4fb7-b898-d851a4fd9577 at <https://proxy.business.githubcopilot.com/v1/engines/gpt-4o-copilot/completions> finished with 200 status after 420.9779579999995ms"}}

logMessage (notification)

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

inlineCompletion (response)

{"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)

{"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)

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

didChange (call)

{"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)

{"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)

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[fetchCompletions] Request d30dc207-9119-49d5-94f4-77630cc21038 at <https://proxy.business.githubcopilot.com/v1/engines/gpt-4o-copilot/completions> finished with 200 status after 179.9752499999995ms"}}

logMessage (notification)

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

inlineCompletion (response)

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

didChange (call)

{"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)

{"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)

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[fetchCompletions] Request bb7d86a2-fdab-4cb1-b0bc-a50e257da4d3 at <https://proxy.business.githubcopilot.com/v1/engines/gpt-4o-copilot/completions> finished with 200 status after 261.87508399999933ms"}}

logMessage (notification)

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

inlineCompletion (response)

{"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)

{"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)

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

didChange (call)

{"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)

{"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)

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[fetchCompletions] Request a37a6e57-16e7-4cae-95d5-7223d7b57233 at <https://proxy.business.githubcopilot.com/v1/engines/gpt-4o-copilot/completions> finished with 200 status after 263.04254200000105ms"}}

logMessage (notification)

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

inlineCompletion (response)

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

didChange (call)

{"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)

{"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)

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[fetchCompletions] Request 03b5aa8c-5f6c-4229-8457-2ff872ef0142 at <https://proxy.business.githubcopilot.com/v1/engines/gpt-4o-copilot/completions> finished with 200 status after 365.898459ms"}}

logMessage (notification)

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

inlineCompletion (response)

{"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)

{"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)

{"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)

{"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)

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[fetchCompletions] Request 3d022adc-effa-4b2a-bcd0-339a7e96f5fa at <https://proxy.business.githubcopilot.com/v1/engines/gpt-4o-copilot/completions> finished with 200 status after 374.5305420000004ms"}}

logMessage (notification)

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

inlineCompletion (response)

{"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)

{"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}}}}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions