serve icon indicating copy to clipboard operation
serve copied to clipboard

Crash on symbolic dir links: Error: EISDIR: illegal operation on a directory

Open weijarz opened this issue 5 years ago • 1 comments

Crash on symbolic dir links.

OS: Linux 5.4.39-1-lts Node: v12.16.3 LTS

mkdir /tmp/a && cd /tmp/a
mkdir a b
touch a/a1 b/b1
cd a
ln -s /tmp/a/b .
serve -S

Open http://localhost:5000 then click 'b' folder, then serve crashed.

INFO: Gracefully shutting down. Please wait...
events.js:287
      throw er; // Unhandled 'error' event
      ^

Error: EISDIR: illegal operation on a directory, read
Emitted 'error' event on ReadStream instance at:
    at internal/fs/streams.js:186:12
    at FSReqCallback.wrapper [as oncomplete] (fs.js:488:5) {
  errno: -21,
  code: 'EISDIR',
  syscall: 'read'
}

weijarz avatar May 26 '20 06:05 weijarz

I'm seeing the same error. It happens when a symlinked directory is accessed without a trailing slash.

node:events:498
      throw er; // Unhandled 'error' event
      ^

Error: EISDIR: illegal operation on a directory, read
Emitted 'error' event on ReadStream instance at:
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -21,
  code: 'EISDIR',
  syscall: 'read'
}

The error does not happen if the trailingSlash option is set to true.

https://github.com/vercel/serve-handler#trailingslash-boolean

eliot-akira avatar Apr 20 '22 02:04 eliot-akira