Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error with eslint due to variable initialization before checking, eslint was set #1154

Closed
wesoledi opened this issue Oct 1, 2022 · 7 comments
Labels
Bug Bug Fix Status: Waiting Feedback Needs feedback from the author

Comments

@wesoledi
Copy link
Contributor

wesoledi commented Oct 1, 2022

In some projects, with symfony 6 with encore used, to work with sass+vue, without external eslint configuration, there may be error while building final dist/build files. The reason was, it could not init eslint, even it was disabled in webpack configuration (or more precisly: not enabled). Webpack-encore still wanted to run it, before checking if "useEslintPlugin" was set.

To fix this, I moved variable initialization to the block, after checking this variable, because it is used only inside if-block anyway. So there is no need to init these before.

Here is my compare: bc34f91

@weaverryan
Copy link
Member

Hi there!

What is the exact error that you get when building for production? And was it necessary to move all of those require statements? Or is there just 1 specifically that fixes the problem.

Your situation makes sense... but I am having a hard time seeing why any of those require statements would cause a problem. But seeing the error might help clarify :).

Cheers!

@weaverryan weaverryan added Bug Bug Fix Status: Waiting Feedback Needs feedback from the author labels Oct 3, 2022
@lu43n
Copy link

lu43n commented Oct 8, 2022

The same here. With fix https://github.com/symfony/webpack-encore/commit/bc34f910dfa189016a6f7563927ea752479c0695 from @wesoledi everything works. Before fix I got errors:

yarn run v1.22.17
$ /usr/home/account/domains/domain.com/node_modules/.bin/encore dev
Running webpack ...

events.js:377
      throw er; // Unhandled 'error' event
      ^

Error: listen EPERM: operation not permitted 0.0.0.0:20868
    at Server.setupListenHandle [as _listen2] (net.js:1314:21)
    at listenInCluster (net.js:1379:12)
    at Server.listen (net.js:1465:7)
    at Object.<anonymous> (/usr/home/account/domains/domain.com/node_modules/sync-rpc/lib/worker.js:68:8)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
    at internal/main/run_main_module.js:17:47
Emitted 'error' event on Server instance at:
    at emitErrorNT (net.js:1358:8)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  code: 'EPERM',
  errno: -1,
  syscall: 'listen',
  address: '0.0.0.0',
  port: 20868
}
[webpack-cli] Failed to load '/usr/home/account/domains/domain.com/webpack.config.js' config
[webpack-cli] Error: Timed out waiting for sync-rpc server to start (it should respond with "pong" when sent "ping"):

events.js:377
      throw er; // Unhandled 'error' event
      ^

Error: connect ECONNREFUSED 127.0.0.1:20868
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  errno: -61,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 20868
}


    at waitForAlive (/usr/home/account/domains/domain.com/node_modules/sync-rpc/lib/index.js:85:11)
    at start (/usr/home/account/domains/domain.com/node_modules/sync-rpc/lib/index.js:41:3)
    at sendMessage (/usr/home/account/domains/domain.com/node_modules/sync-rpc/lib/index.js:133:17)
    at createClient (/usr/home/account/domains/domain.com/node_modules/sync-rpc/lib/index.js:173:27)
    at Object.<anonymous> (/usr/home/account/domains/domain.com/node_modules/@symfony/webpack-encore/lib/plugins/eslint.js:13:32)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
error Command failed with exit code 2.

@wesoledi
Copy link
Contributor Author

wesoledi commented Oct 8, 2022

Yes :) yes, it was it: sync-rpc error. Thx @lu43n.

@Kocal
Copy link
Member

Kocal commented Oct 8, 2022

Interesting, maybe we can reconsider solutions described in #985 (comment)...

But for now, can someone of you can open a PR for bc34f91 ? Thanks

@wesoledi
Copy link
Contributor Author

wesoledi commented Oct 9, 2022

created

@Kocal
Copy link
Member

Kocal commented Oct 9, 2022

Thanks!

TomaszGasior added a commit to TomaszGasior/RadioLista-v3 that referenced this issue Feb 18, 2023
This commit reverts part of 6ec9eaf

New version of Webpack Encore is not compatible with shared hosting.
symfony/webpack-encore#1154
symfony/webpack-encore#1175

Fixes #218
@Kocal
Copy link
Member

Kocal commented Aug 30, 2024

Closing, as ESLint integration has been removed in #1309 for the next major version of Encore (5).

@Kocal Kocal closed this as completed Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug Fix Status: Waiting Feedback Needs feedback from the author
Projects
None yet
Development

No branches or pull requests

4 participants