elm-live icon indicating copy to clipboard operation
elm-live copied to clipboard

elm-live crash when a file is not found instead responding with a 404

Open lucamug opened this issue 4 years ago • 4 comments

If you try an url for a non existing file, for example: http://localhost:8000/xyz/index.html

elm-live will stop with the error:

internal/fs/utils.js:537
    throw new ERR_INVALID_ARG_TYPE(propName, ['string', 'Buffer', 'URL'], path);
    ^
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
    at readFile (fs.js:313:10)
    at /Users/userName/projectName/node_modules/crocks/Async/index.js:54:10
    at Object.fork (/Users/userName/projectName/node_modules/crocks/Async/index.js:155:20)
    at /Users/userName/projectName/node_modules/crocks/Async/index.js:254:41
    at settle (/Users/userName/projectName/node_modules/crocks/Async/index.js:151:16)
    at ReadFileContext.callback (/Users/userName/projectName/node_modules/crocks/Async/index.js:56:47)
    at FSReqCallback.readFileAfterOpen [as oncomplete] (fs.js:257:13) {
  code: 'ERR_INVALID_ARG_TYPE'
}
node /Users/userName/projectName/elm-start/src-js/start.js serverDev exited with code 0

Could be related to

https://github.com/wking-io/elm-live/issues/207 https://github.com/wking-io/elm-live/issues/205 https://github.com/wking-io/elm-live/issues/195

lucamug avatar Jul 06 '20 08:07 lucamug

I can confirm this issue. I saw it after checking a fresh repo and freshly installing elm-live. I guess it was trying to load the index before it was fully built

elm-live --version
4.0.2
git:(master) elm-live src/Main.elm --open

elm-live:
  Server has been started! Server details below:
    - Website URL: http://localhost:8000
    - Serving files from: /Users/foo/xxx/glmorph


internal/fs/utils.js:535
    throw new ERR_INVALID_ARG_TYPE(propName, ['string', 'Buffer', 'URL'], path);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
    at readFile (fs.js:313:10)
    at /Users/foo/.nvm/versions/node/v12.16.3/lib/node_modules/elm-live/node_modules/crocks/Async/index.js:54:10
    at Object.fork (/Users/foo/.nvm/versions/node/v12.16.3/lib/node_modules/elm-live/node_modules/crocks/Async/index.js:155:20)
    at /Users/foo/.nvm/versions/node/v12.16.3/lib/node_modules/elm-live/node_modules/crocks/Async/index.js:254:41
    at settle (/Users/foo/.nvm/versions/node/v12.16.3/lib/node_modules/elm-live/node_modules/crocks/Async/index.js:151:16)
    at ReadFileContext.callback (/Users/foo/.nvm/versions/node/v12.16.3/lib/node_modules/elm-live/node_modules/crocks/Async/index.js:56:47)
    at FSReqCallback.readFileAfterOpen [as oncomplete] (fs.js:257:13) {
  code: 'ERR_INVALID_ARG_TYPE'
}

francisdb avatar Aug 17 '20 07:08 francisdb

Anyone have a fork with this fixed? Been dealing with this same issue as well.

erlandsona avatar Jan 31 '21 14:01 erlandsona

Anyone have a fork with this fixed? Been dealing with this same issue as well.

At work we use elm-go, a clone that we made to fix some issues of elm-live

lucamug avatar Feb 11 '21 22:02 lucamug

This occurs when the index.html file is missing from the --dir

helldorado avatar Apr 02 '24 11:04 helldorado