Skip to content

Fail to create tls-proxy for the second process. #2200

Closed
@huangy10

Description

@huangy10
  • Web Browser: Chrome
  • Local OS: Windows 10
  • Remote OS: Ubuntu 16.04
  • Remote Architecture: x86_64
  • code-server --version: 3.5.0

When running two process in the same server by two different users, the second one won't work and gives the following error:

discarding socket connection: EACCES: permission denied, unlink '/tmp/code-server/tls-proxy'

Notice that the tls-proxy is created by the first process. Obviously, it is not accessible by the second process.

After a little research, I find out that this bug is caused by a logic error in socket.ts, line 94.

public async findFreeSocketPath(basePath: string, maxTries = 100): Promise<string> {
    let i = 0
    let path = basePath
    while ((await canConnect(path)) && i < maxTries) { // the line with bug
      path = `${basePath}-${++i}`
    }
    return path
  }

which should be

public async findFreeSocketPath(basePath: string, maxTries = 100): Promise<string> {
    let i = 0
    let path = basePath
    while (!(await canConnect(path)) && i < maxTries) { // fix the bug
      path = `${basePath}-${++i}`
    }
    return path
  }

When the current path is not accessible, then try next one.

What is interesting is that when the second user is root, then canConnect returns true in the original code, a new socket file tls-proxy-1 is created successfully. So that I think the code here should be further modified. We should check if there is a file in path. If there is a file here, we should not use this even it is accessible unless the current user is not root.


There is another problem here: the directory /tmp/code-server is created and owned by the first user, which means this directory is not writable for the second user, so the new socket file tls-proxy-1 cannot be created. I have to manually change the permissions of the directory to make everything works.


Ok I forget one last thing. When I fix every as discribed above, the web client still shows nothing. After checking chrome console, a 404 error occurs for file in path code-server/release-standalone/dist/pages/pages/vscode.js. Notice that there are two pages here, while the structure of the dist folder is dist/pages/vscode.js. I have to manually create another pages folder, and copy everything else into it.

finally, everything works fine.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions