javascript-typescript-langserver icon indicating copy to clipboard operation
javascript-typescript-langserver copied to clipboard

Eaccess error on unreadable file

Open pockata opened this issue 6 years ago • 8 comments

Current behavior:

When running the typescript server in a project where one or more files/folders are unreadable (eg. owned by a different user) the language server throws and error and stops working.

Here is the log:

ERROR Handle textDocumentDidOpen: { Error: EACCES: permission denied, scandir '/home/user/Projects/Project/unreadable-dir'
  errno: -13,
  code: 'EACCES',
  syscall: 'scandir',
  path: '/home/user/Projects/Project/unreadable-dir' }
ERROR Handler for textDocument/completion failed: { Error: EACCES: permission denied, scandir '/home/user/Projects/Project/unreadable-dir'
  errno: -13,
  code: 'EACCES',
  syscall: 'scandir',
  path: '/home/user/Projects/Project/unreadable-dir' } 
Message: { jsonrpc: '2.0',
  method: 'textDocument/completion',
  params: 
   { position: { character: 1, line: 17 },
     textDocument: { uri: 'file:///home/user/Projects/Project/unreadable-dir/unreadable-file.js' } },
  id: 22 }
ERROR Handler for textDocument/completion failed: { Error: EACCES: permission denied, scandir '/home/user/Projects/Project/unreadable-dir'
  errno: -13,
  code: 'EACCES',
  syscall: 'scandir',
  path: '/home/user/Projects/Project/unreadable-dir' } 
Message: { jsonrpc: '2.0',
  method: 'textDocument/completion',
  params: 
   { position: { character: 2, line: 17 },
     textDocument: { uri: 'file:///home/user/Projects/Project/unreadable-dir/unreadable-file.js' } },
  id: 25 }
ERROR Handler for textDocument/completion failed: { Error: EACCES: permission denied, scandir '/home/user/Projects/Project/unreadable-dir'
  errno: -13,
  code: 'EACCES',
  syscall: 'scandir',
  path: '/home/user/Projects/Project/unreadable-dir' } 
Message: { jsonrpc: '2.0',
  method: 'textDocument/completion',
  params: 
   { position: { character: 3, line: 17 },
     textDocument: { uri: 'file:///home/user/Projects/Project/unreadable-dir/unreadable-file.js' } },
  id: 26 }
ERROR Handler for textDocument/rename failed: { Error: EACCES: permission denied, scandir '/home/user/Projects/Project/unreadable-dir'
  errno: -13,
  code: 'EACCES',
  syscall: 'scandir',
  path: '/home/user/Projects/Project/unreadable-dir' } 
Message: { jsonrpc: '2.0',
  method: 'textDocument/rename',
  params: 
   { newName: 'fse',
     position: { character: 0, line: 17 },
     textDocument: { uri: 'file:///home/user/Projects/Project/unreadable-dir/unreadable-file.js' } },
  id: 29 }
ERROR Handle textDocumentDidSave: { Error: EACCES: permission denied, scandir '/home/user/Projects/Project/unreadable-dir'
  errno: -13,
  code: 'EACCES',
  syscall: 'scandir',
  path: '/home/user/Projects/Project/unreadable-dir' }
ERROR Handle textDocumentDidSave: { Error: EACCES: permission denied, scandir '/home/user/Projects/Project/unreadable-dir'
  errno: -13,
  code: 'EACCES',
  syscall: 'scandir',
  path: '/home/user/Projects/Project/unreadable-dir' }
ERROR Handle textDocumentDidSave: { Error: EACCES: permission denied, scandir '/home/user/Projects/Project/unreadable-dir'
  errno: -13,
  code: 'EACCES',
  syscall: 'scandir',
  path: '/home/user/Projects/Project/unreadable-dir' }

Expected behavior:

Resume normal operation and possibly print a warning.

Steps to reproduce:

1. Open an existing typescript project
2. Create a file and a folder
    `mkdir -p unreadable-dir && touch unreadable-dir/unreadable-file.js`
3. Change ownership
    `sudo chown root:root -R unreadable-dir && sudo chmod -R 0700 unreadable-dir`

Additional info:

OS: Antergos Linux Editor: Neovim v0.3.1 Language client: github.com/autozimu/LanguageClient-neovim Typescript langserver version: v2.9.4 Command: javascript-typescript-stdio --logfile /tmp/langclient.txt

pockata avatar Jul 25 '18 11:07 pockata

From your logs, it looks like the handler just returns an error. Are sure the process is crashing? What would you expect to happen?

felixfbecker avatar Jul 25 '18 15:07 felixfbecker

Sorry, my mistake. I just checked the process list and the typescript lang server seems to be working.

I thought it crashed because all the functionality provided by the language client (autocomplete, rename, etc.) stops working and spits out the error "Error: EACCESS... " - the same one from the log.

I assumed this was an issue with the lang server and not the client because the other language servers I have installed (html, css, php) work normally, e.g. don't throw errors, autocomplete is working, etc.

But it seems it might actually be an issue with the client.

@autozimu can you weigh in on this?

pockata avatar Jul 26 '18 14:07 pockata

If the file is not readable by the user, there is nothing can be done. What do you expect in this case?

autozimu avatar Jul 27 '18 01:07 autozimu

When the unreadable file is present in a project, no matter what .js file I open, the typescript server throws the error and LanguageClient-neovim stops working normally and just echoes the same error message.

I've attached two screenshots, one with the unreadable file and one without. For the test, I've used a bare folder with the test.js file and @types/node installed.

test.js without the unreadable file in the same folder.

TestFolder/
  -- test.js

Everything works as expected. screenshot-2018-07-27-20_29_45

test.js with the unreadable file in the same folder.

TestFolder/
  -- test.js
  -- unreadable-file.js

Autocomplete items are no longer available. Functions like LanguageClient_textDocument_rename() just show the error in the statusline. screenshot-2018-07-27-20_30_23

pockata avatar Jul 27 '18 17:07 pockata

This error could probably be handled better, but is there a reason you can't just make the file accessible?

felixfbecker avatar Jul 27 '18 18:07 felixfbecker

It's a new project we inherited. The setup is "interesting". When running a dev environment, a ton of docker containers run and create a bunch of folders which are unreadable to the current user. These folders contain anything from access logs to mysql data dirs and more. Changing the permissions, messes up everything, so we're stuck with this for the time being because sorting this out will take some time.

pockata avatar Aug 02 '18 19:08 pockata

@felixfbecker In my case I can't just make the file accessible:

  1. The file is in a directory above my typescript project, so not sure why it's stopping the server working.
  2. This file is used by a postgresql container (via volume mount) with its own user, I can't change the permissions on it.

insidewhy avatar Nov 17 '18 11:11 insidewhy

@felixfbecker In my case I can't just make the file accessible:

  1. The file is in a directory above my typescript project, so not sure why it's stopping the server working.
  2. This file is used by a postgresql container (via volume mount) with its own user, I can't change the permissions on it.

I have exactly the same problem, but with a mongodb container creating files via volume mounts.

The volume mount (created by the docker container) is located in a directory next to the typescript project. However, the LC redirects project root to the parent folder and then tries to scan the volume mount.

jaklec avatar Dec 10 '18 09:12 jaklec