eclipse-che / che

Kubernetes based Cloud Development Environments for Enterprise Teams
http://eclipse.org/che
Eclipse Public License 2.0
6.98k stars 1.19k forks source link

Logging to the console from a plug-in may cause the cyclic messaging #18598

Open azatsarynnyy opened 3 years ago

azatsarynnyy commented 3 years ago

Describe the bug

If a plug-in logs to the console from vscode.TextDocumentChangeEvent listener function it leads to the cyclic messaging.

Investigation details.

When a plug-in writes to the console the messages are forwarded to Che-Theia output channel. Output channel widget's content is rendered with Monaco editor. That means every message sent to the console adds a content to a Monaco editor which fires it's onDidChangeContent event. This event is passed to the plug-in system. If a plug-in sets a listener with vscode.workspace.onDidChangeTextDocument Plug-in API and logs to the console from inside the listener function it causes the cyclic messaging. E.g.:

import * as vscode from "vscode";
export function activate(context: vscode.ExtensionContext) {
  vscode.workspace.onDidChangeTextDocument(
    (e: vscode.TextDocumentChangeEvent) => console.log(e.document.fileName)
  );
}

Note, the issue isn't reproduced on upstream Theia.

Che version

Steps to reproduce

  1. Create a Workspace from the Devfile below:
    apiVersion: 1.0.0
    metadata:
    name: text-document-api-test
    attributes:
    persistVolumes: 'false'
    components:
    - type: chePlugin
    reference: 'https://raw.githubusercontent.com/azatsarynnyy/text-document-api-test/main/meta.yaml'
  2. Open hosted-instance-log output channel view (View->Output).

Expected behavior

console.log from inside a vscode.workspace.onDidChangeTextDocument listener function shouldn't cause firing Monaco's onDidChangeContent event.

Runtime

Screenshots

Peek 2020-12-11 08-04

Installation method

Environment

Eclipse Che Logs

Additional context

azatsarynnyy commented 3 years ago

I've filed the related upstream issue https://github.com/eclipse-theia/theia/issues/8855 If we decide it's an upstream bug then fixing it upstream will fix this one as well, in Che-Theia. If https://github.com/eclipse-theia/theia/issues/8855 is a feature then we should investigate how to fix it in Che-Theia.

tsmaeder commented 3 years ago

Not sure if it's related: https://github.com/eclipse/che-theia/pull/528

azatsarynnyy commented 3 years ago

Not sure if it's related: eclipse/che-theia#528

It seems related. Thanks!

che-bot commented 3 years ago

Issues go stale after 180 days of inactivity. lifecycle/stale issues rot after an additional 7 days of inactivity and eventually close.

Mark the issue as fresh with /remove-lifecycle stale in a new comment.

If this issue is safe to close now please do so.

Moderators: Add lifecycle/frozen label to avoid stale mode.

tsmaeder commented 3 years ago

It ain't going away until we fix it :-)