dherault / serverless-offline

Emulate AWS λ and API Gateway locally when developing your Serverless project
MIT License
5.19k stars 796 forks source link

Upgrading from v8.8.1 to 9.1 or beyond causes a weird issue with the IntelliJ debugger and the app #1655

Open risingfish opened 1 year ago

risingfish commented 1 year ago

I'm currently running serverless-offline v8.8.2 in a project. Yesterday I updated it all the way to the latest v12.0.4, and running my project works fine when I am not debugging. The second I attach a debugger using the IntelliJ "Attach to Node.js/Chrome" run configuration, the local app stops responding. Additionally, app won't stop after repeatedly pressing Ctrl+C and the only way to stop it is to kill the terminal session I ran it in.

I've been doing some troubleshooting and have discovered that this behavior first shows up in v9.1.0, and is in every version after that. Looking through the release notes for 9.1 it looks like the way serverless-offline exits was changed in version 9.1.0, so maybe related? I've setup a simple GitHub repo with the bare minimum to reproduce this issue at https://github.com/risingfish/serverless-offline-intellij-debug-bug, and I am hoping someone could take a look and see if I am doing something wrong or it it's is an actual bug.

One thing I have discovered is in the serverless.yaml file, if I remove the httpPort specification the problem seems to go away unless I leave the project running for a while (say, if I go to lunch). I needed that earlier, but can run without it now.

My dev environment is: Windows 10 + WSL2 (The serverless app is running in WSL2 and I am also running IntelliJ from WSL2) NodeJS 16.17.1 IntelliJ 2023.3.1