eclipse-theia / theia

Eclipse Theia is a cloud & desktop IDE framework implemented in TypeScript.
http://theia-ide.org
Eclipse Public License 2.0
20.03k stars 2.5k forks source link

[debug] debug-ext prematurely fires `didStart` event on `didCreate` #11916

Closed kittaakos closed 1 year ago

kittaakos commented 1 year ago

Bug Description:

As the title says, the debug-ext will incorrectly fire the didStart event, on didCreate and will call the debug adapter. It's too early.

https://github.com/eclipse-theia/theia/blob/b58de21ca1a9371ffe8779919a174e85781cfe5a/packages/plugin-ext/src/plugin/debug/debug-ext.ts#L248-L253

Some debug adapters will run custom DAP requests on session start, such as the cortex-debug extension here, and will break, as the session has not been initialized yet.

2022-11-24T13:19:18.818Z root ERROR [hosted-plugin: 30330] /Users/a.kitta/dev/git/theia/plugins/cortex-debug/extension/dist/debugadapter.js:16423
            if (this.serverController.customRequest(command, response, args)) {
                                      ^

TypeError: Cannot read properties of undefined (reading 'customRequest')
    at GDBDebugSession.<anonymous> (/Users/a.kitta/dev/git/theia/plugins/cortex-debug/extension/dist/debugadapter.js:16423:39)
    at Generator.next (<anonymous>)
    at /Users/a.kitta/dev/git/theia/plugins/cortex-debug/extension/dist/debugadapter.js:15519:71
    at new Promise (<anonymous>)
    at __webpack_modules__../src/gdb.ts.__awaiter (/Users/a.kitta/dev/git/theia/plugins/cortex-debug/extension/dist/debugadapter.js:15515:12)
    at GDBDebugSession.customRequest (/Users/a.kitta/dev/git/theia/plugins/cortex-debug/extension/dist/debugadapter.js:16418:16)
    at GDBDebugSession.dispatchRequest (/Users/a.kitta/dev/git/theia/plugins/cortex-debug/extension/dist/debugadapter.js:515:22)
    at GDBDebugSession.dispatchRequest (/Users/a.kitta/dev/git/theia/plugins/cortex-debug/extension/dist/debugadapter.js:1183:15)
    at GDBDebugSession.handleMessage (/Users/a.kitta/dev/git/theia/plugins/cortex-debug/extension/dist/debugadapter.js:1364:18)
    at GDBDebugSession._handleData (/Users/a.kitta/dev/git/theia/plugins/cortex-debug/extension/dist/debugadapter.js:1458:34)

Steps to Reproduce:

  1. Get the 1.5.1 cortex-debug VSIX from my fork: https://github.com/kittaakos/cortex-debug/raw/1.5.1/marus25.cortex-debug-1.5.1-development.vsix
  2. Configure the debug session based on the official documentation: https://github.com/Marus/cortex-debug#installation
  3. Start the debug session

Additional Information

kittaakos commented 1 year ago

Please assign this to me. Thanks!