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

Windows: npm run e2e does not properly clean up resources #38

Closed
shazron opened this issue May 14, 2024 · 5 comments · Fixed by #40
Closed

Windows: npm run e2e does not properly clean up resources #38

shazron opened this issue May 14, 2024 · 5 comments · Fixed by #40
Labels
bug Something isn't working Windows

Comments

@shazron
Copy link
Member

shazron commented May 14, 2024

Windows 11 x86, node-18, Windows Terminal with Powershell 7.

There are 2 node processes that are left running.

If you run npm run e2e once, everything will be fine, then the tests exit.
But if you run it again, it will complain about Error: listen EADDRINUSE: address already in use :::35729 (for livereload).
Something is not being cleaned up in Windows, but it is fine on macOS.

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

Error: listen EADDRINUSE: address already in use :::35729
    at Server.setupListenHandle [as _listen2] (node:net:1740:16)
    at listenInCluster (node:net:1788:12)
    at Server.listen (node:net:1876:7)
    at Server.listen (C:\Users\shazr\Documents\git\work\adobe\aio-cli-plugin-app-dev\node_modules\livereload\lib\livereload.js:83:28)
    at exports.createServer (C:\Users\shazr\Documents\git\work\adobe\aio-cli-plugin-app-dev\node_modules\livereload\lib\livereload.js:256:14)
    at runDev (C:\Users\shazr\Documents\git\work\adobe\aio-cli-plugin-app-dev\src\lib\run-dev.js:109:41)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Dev.runOneExtensionPoint (C:\Users\shazr\Documents\git\work\adobe\aio-cli-plugin-app-dev\src\commands\app\dev\index.js:170:56)
    at async Dev.run (C:\Users\shazr\Documents\git\work\adobe\aio-cli-plugin-app-dev\src\commands\app\dev\index.js:59:7)
    at async Dev._run (C:\Users\shazr\Documents\git\work\adobe\aio-cli-plugin-app-dev\node_modules\@oclif\core\lib\command.js:117:22)
Emitted 'error' event on Server instance at:
    at Server.onError (C:\Users\shazr\Documents\git\work\adobe\aio-cli-plugin-app-dev\node_modules\livereload\lib\livereload.js:102:19)
    at WebSocketServer.emit (node:events:513:28)
    at Server.emit (node:events:513:28)
    at emitErrorNT (node:net:1767:8)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'EADDRINUSE',
  errno: -4091,
  syscall: 'listen',
  address: '::',
  port: 35729
}
2024-05-14_22-40-15

Workaround

  1. Open Task Manager
  2. Search for node
  3. End task for any node processes you find
@shazron shazron added the bug Something isn't working label May 14, 2024
@shazron shazron changed the title npm run e2e does not properly clean up resources Windows 11: npm run e2e does not properly clean up resources May 14, 2024
@shazron shazron changed the title Windows 11: npm run e2e does not properly clean up resources Windows: npm run e2e does not properly clean up resources May 14, 2024
@aiojbot
Copy link

aiojbot commented May 14, 2024

JIRA issue created: https://jira.corp.adobe.com/browse/ACNA-2988

@shazron
Copy link
Member Author

shazron commented May 15, 2024

The aio app dev command is fine when run stand-alone, it's when its called via npm run e2e do the two node processes linger - so it must be cleanup of the exec calls.

@shazron
Copy link
Member Author

shazron commented May 15, 2024

Looks like it may be an execa/node issue in Windows (still investigating): sindresorhus/execa#433

@shazron
Copy link
Member Author

shazron commented May 16, 2024

One of the node processes is actually a background process - a child process of CCXProcess (part of CC Deskop), red herring. The remaining orphan node process is our server process not being killed.

@shazron
Copy link
Member Author

shazron commented May 16, 2024

Try to use spawn directly (see this) - when I get the child pid from the execa call, it does not exist when I try to kill it later. execa launches a shell (in this case cmd.exe), even when shell: false, windowsHide: false, and in turn, calls the node script, which probably is the process we need, not the cmd.exe process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants