hotel
hotel copied to clipboard
Fix ERR_INVALID_ARG_TYPE exception in call to writeFileSync()
Running on MacOS 10.15.7 (Catalina)
Originally I installed and ran Hotel like this:
chown -R moxley:admin /usr/local/lib/node_modules
npm install -g hotel
hotel start
No errors were returned, and when I tried to access the hotel HTTP service, nothing was listening:
$ curl localhost:2000
curl: (7) Failed to connect to localhost port 2000: Connection refused
This matches the behavior described in #344.
Next, I cloned the hotel repo, and ran it like this:
npm i
npm start
The following error showed up in the server output:
15:16:55 - Watching /Users/moxley/.hotel/servers
create /Users/moxley/.hotel/daemon.pid 3609
internal/fs/utils.js:779
throw new ERR_INVALID_ARG_TYPE(
^
TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (3609)
at Object.writeFileSync (fs.js:1460:5)
at Object.create (/usr/local/lib/node_modules/hotel/lib/pid-file.js:18:13)
at Object.<anonymous> (/usr/local/lib/node_modules/hotel/lib/daemon/index.js:20:9)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: 'ERR_INVALID_ARG_TYPE'
After editing src/pid-file.js, converting the numeric port to a string, the service ran without errors.
I tested this locally on OS X 11.2.3
with node 15.12.0
and npm 7.7.4
. Tests and linter pass, server runs as expected.
Steps:
$ git clone [email protected]:typicode/hotel.git && cd hotel
$ gh pr checkout 372
$ npm install
$ npm run build # tests fail if you don't run build first
$ npm test
$ npm start
Note npm install
generated a new package-lock.json
with "lockfileVersion": 2
and updates to the dependency tree. I think the new package-lock.json
should be included with the PR.
Note npm install generated a new package-lock.json with "lockfileVersion": 2 and updates to the dependency tree. I think the new package-lock.json should be included with the PR.
@kenkunz: I've made no changes to package.json. If you got changes to package-lock.json, that has nothing to do with this PR. It has to do with the version of npm you have.
duplicate of https://github.com/typicode/hotel/pull/361