#NestJS hanging after receiving request (containerized on WSL2 via docker-desktop)

14 messages · Page 1 of 1 (latest)

cold token
#

Context: NestJS running in a dockerized environment along with database (mysql) and redis containers. There's two containers of the same codebase running as two separate containers app & worker.

The app suddenly hangs with no error messages. Can't stop the docker container either unless I kill the docker desktop process and remove it after restarting docker desktop. Can't reload changes etc.

I have turned on debug logs, nothing appears. It just hangs. I have reinstalled, downgraded docker desktop, tried multiple different wsl2 Linux distros, cleared dist folder, deleted node_modules, removed all docker resources and rebuilt docker images over 20 times.

#

Current dependencies

#

"@mikro-orm/cli": "^5.7.4",
"@mikro-orm/core": "^5.7.4",
"@mikro-orm/migrations": "^5.7.4",
"@mikro-orm/mysql": "^5.7.4",
"@mikro-orm/nestjs": "^5.1.8",
"@mikro-orm/reflection": "^5.7.4",
"@mikro-orm/seeder": "^5.7.4",
"@nestjs-modules/mailer": "^1.6.1",
"@nestjs/axios": "2.0.0",
"@nestjs/bull": "^0.5.4",
"@nestjs/common": "^8.0.0",
"@nestjs/config": "^2.3.1",
"@nestjs/core": "^8.0.0",
"@nestjs/event-emitter": "^1.1.1",
"@nestjs/jwt": "^8.0.0",
"@nestjs/mapped-types": "*",
"@nestjs/passport": "^8.2.1",
"@nestjs/platform-express": "^8.0.0",
"@nestjs/schedule": "^2.0.1",
"@nestjs/throttler": "^3.1.0",

#

The issue is also very random, it's hard to pin point what causes it. I've also been monitoring memory usage for leaks but it stays consistent. When the hang happens, CPU usage goes to 0-2%

This is the docker top output after the hang and after i've tried to remove the containers

app
UID    PID     PPID    C    STIME   TTY   TIME       CMD
root   10926   10612   21   May04   ?     00:05:11   [node] <defunct>
root   11120   10612   1    May04   ?     00:00:19   node -r source-map-support/register --inspect /usr/src/app/dist/src/main

database
UID   PID     PPID    C    STIME   TTY   TIME       CMD
999   10338   10317   0    May04   ?     00:00:01   mysqld

worker
UID    PID     PPID    C    STIME   TTY   TIME       CMD
root   10914   10613   20   May04   ?     00:05:04   [node] <defunct>
root   11131   10613   1    May04   ?     00:00:17   node -r source-map-support/register /usr/src/app/dist/src/worker
#

At this point i can't even close docker-desktop. I need to kill via task manager, restart, purge the wsl data to start docker

#

If anyone has any insight I would greatly appreciate it! This has been so stressful as i haven't been able to get work done for 4 days

#

Current tsconfig.json

{
    "compilerOptions": {
        "module": "commonjs",
        "declaration": true,
        "removeComments": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "allowSyntheticDefaultImports": true,
        "target": "es2018",
        "sourceMap": true,
        "outDir": "./dist",
        "baseUrl": "./",
        "incremental": false,
        "skipLibCheck": true,
        "strictNullChecks": false,
        "noImplicitAny": false,
        "strictBindCallApply": false,
        "forceConsistentCasingInFileNames": false,
        "noFallthroughCasesInSwitch": false,
        "esModuleInterop": true,
        "resolveJsonModule": true,
        "typeRoots": [
            "node_modules/@types",
            "src/typings"
        ]
    },
    "watchOptions": {
        "watchFile": "fixedpollinginterval",
    }
}
lusty holly
#

Are you running Nest in dev mode? i.e. watching for file changes to restart the server?

tropic maple
cold token
#

yes tried with shutdown hooks enabled & disabled.

#

The container hangs along with the database container. Can't kill either

#

I'm running start:dev. these are my commands
"start:dev:core": "nest start --watch",

#

Super frustrating, idk where the issue is. No errors, just hangs. Any insight would be greatly appreciated!!!

lusty holly
#

So, to recap the issue and how it happens.

You run the container, Nest runs.
You make a change, Nest hangs.