Skip to content

Vite dev server exits without message (fix in report) #15

@ericwang401

Description

@ericwang401
  • Laravel Vite Plugin Version: 0.1.3
  • Laravel Version: 9.17.0
  • Node Version: 18.3.0
  • NPM Version: 8.11.0

Description:

When running the Vite dev server using npm run dev, the development server starts up with

root@2731f07e003e:/app# npm run dev

> dev
> vite --host 0.0.0.0


  vite v2.9.12 dev server running at:

  > Local:    http://localhost:3000/
  > Network:  http://172.21.0.4:3000/

  ready in 506ms.


  Laravel v9.17.0 

  > APP_URL: http://localhost

But closes unexpectedly a second after running the command with no messages or error messages whatsoever.

I did some debugging and commented out process.exit(); in

const clean = () => {
    if (fs_1.default.existsSync(hotFile)) {
        fs_1.default.rmSync(hotFile);
    }
    process.exit();
};

and this finally made the dev server spit out the following error

root@2731f07e003e:/app# npm run dev

> dev
> vite --host 0.0.0.0


  vite v2.9.12 dev server running at:

  > Local:    http://localhost:3000/
  > Network:  http://172.21.0.4:3000/

  ready in 448ms.


  Laravel v9.17.0 

  > APP_URL: http://localhost
node:internal/errors:466
    ErrorCaptureStackTrace(err);
    ^

Error: ENOSPC: System limit for number of file watchers reached, watch '/app/vendor/symfony/mailer/Transport/Smtp/Auth/XOAuth2Authenticator.php'
    at FSWatcher.<computed> (node:internal/fs/watchers:244:19)
    at Object.watch (node:fs:2306:34)
    at createFsWatchInstance (/app/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:45512:17)
    at setFsWatchListener (/app/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:45559:15)
    at NodeFsHandler$1._watchWithNodeFs (/app/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:45714:14)
    at NodeFsHandler$1._handleFile (/app/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:45778:23)
    at NodeFsHandler$1._addToNodeFs (/app/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:46020:21)
Emitted 'error' event on FSWatcher instance at:
    at FSWatcher._handleError (/app/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:47208:10)
    at NodeFsHandler$1._addToNodeFs (/app/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:46028:18) {
  errno: -28,
  syscall: 'watch',
  code: 'ENOSPC',
  path: '/app/vendor/symfony/mailer/Transport/Smtp/Auth/XOAuth2Authenticator.php',
  filename: '/app/vendor/symfony/mailer/Transport/Smtp/Auth/XOAuth2Authenticator.php'
}

Node.js v18.3.0

A fix for users that use this package on Linux is running this command
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
It will automatically adjust the system watcher limit and make the changes live.

Steps To Reproduce:

I am using Ubuntu 20.04.4 server LTS x86_64
and Docker version 20.10.16, build aa7e414 with Docker compose v2

  1. Clone https://github.com/ericwang401/testing-laravel-vite
  2. Run docker compose up -d
  3. Enter into the workspace container docker compose exec workspace bash
  4. Install dependencies composer i && npm i
  5. Start the dev server npm run dev
    (make sure you went into node_modules and commented out process.exit in the Laravel Vite plugin cleanup function)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions