che icon indicating copy to clipboard operation
che copied to clipboard

Che code loading twice at workspace startup

Open l0rd opened this issue 3 years ago • 4 comments

Describe the bug

When starting a che-code based workspace the IDE gets loaded a first time and shows an error message (Error loading webview) and after a few seconds gets reloaded:

https://user-images.githubusercontent.com/606959/168334199-bb99188d-51eb-414c-b5f7-f6d5eae7bc4e.mov

Che version

next (development version)

Steps to reproduce

Click here (access to Che dogfooding instance is required).

Expected behavior

VS Code is loaded once.

Runtime

OpenShift

Screenshots

No response

Installation method

OperatorHub

Environment

Amazon

Eclipse Che Logs

No response

Additional context

No response

l0rd avatar May 13 '22 19:05 l0rd

The work on this issue has been postponed. At least, until we fix https://github.com/eclipse/che/issues/21537

azatsarynnyy avatar Jul 19 '22 12:07 azatsarynnyy

We should try replacing ?tkn=eclipse-che with ?folder=${PROJECT_SOURCE}.

l0rd avatar Sep 21 '22 11:09 l0rd

We should try replacing ?tkn=eclipse-che with ?folder=${PROJECT_SOURCE}.

@l0rd it's a good idea. But it works OOTB for ?folder=/projects only. As VS Code doesn't resolve the environment variables passed through the URL query parameters.

Hardcoding ?folder=/projects looks like the following, in Project Explorer: image

That's why we have che-on-start extension that detects the right path VS Code should navigate to, depending on a few conditions.

As I see it, one of the options for fixing that problem would be to move that logic from the extension to the entry point script. In that case we could provide the correct path to the server side instead of redirecting the client.

azatsarynnyy avatar Sep 21 '22 12:09 azatsarynnyy

${PROJECT_SOURCE} should be resolved by the DevWorkspace operator

l0rd avatar Sep 21 '22 13:09 l0rd

So the proposal is to resolve ${PROJECT_SOURCE} when setting a DevWorkspace status.mainUrl.

For example, an endpoint with a path that references $PROJECT_SOURCE and with the attribute type: main:

        endpoints:
          - name: che-code
            attributes:
              type: main
              cookiesAuthEnabled: true
              discoverable: false
              urlRewriteSupported: true
            targetPort: 3100
            exposure: public
            path: '?folder=${PROJECT_SOURCE}'
            secure: false
            protocol: https

should result in a DevWorkspace status where the $PROJECT_SOURCE has been resolved:

"status": {
    (...)
    "mainUrl": "https://workspace1bc9e32c0fcd4aed.apps.mloriedo-devworkspaces.devcluster.openshift.com/che-code/?folder=/projects/my-project",
    "message": "https://workspace1bc9e32c0fcd4aed.apps.mloriedo-devworkspaces.devcluster.openshift.com/che-code/?folder=/projects/my-project",
    "phase": "Running"
  }

I am adding the label area/devworkspace-operator.

l0rd avatar Sep 22 '22 10:09 l0rd

That sounds great! As most of the workspaces are single-root projects, it should fix the problem for the vast majority of cases.

azatsarynnyy avatar Sep 22 '22 11:09 azatsarynnyy

I've found out how we can do the same in VS Code entrypoint. We can pass ${PROJECT_SOURCE} when we start VS Code Server https://github.com/che-incubator/che-code/blob/3072353809a0e30369eb7bddd566a35fdb3c94bd/code/src/vs/server/node/serverEnvironmentService.ts#L46

azatsarynnyy avatar Oct 09 '22 05:10 azatsarynnyy

I've found out how we can do the same in VS Code entrypoint.

We can pass ${PROJECT_SOURCE} when we start VS Code Server

https://github.com/che-incubator/che-code/blob/3072353809a0e30369eb7bddd566a35fdb3c94bd/code/src/vs/server/node/serverEnvironmentService.ts#L46

👍great! Let's do that then

l0rd avatar Oct 09 '22 09:10 l0rd

Fixed by https://github.com/che-incubator/che-code/pull/131. VS Code is loaded x2 faster now.

azatsarynnyy avatar Oct 19 '22 16:10 azatsarynnyy

This issue was not manually cloned into Jira for release notes because VS Code was a Technology Preview feature up until Che 7.56 / DS 3.4, and we don't document known issues or bug fixes for Technology Preview features in DS release notes.

max-cx avatar Jan 12 '23 13:01 max-cx

sync'd to Red Hat JIRA https://issues.redhat.com/browse/CRW-3852

devstudio-release avatar Jan 14 '23 03:01 devstudio-release