akauppi / GroundLevel-firebase-es

[ANCHORED] Stencil for operational web apps
https://groundlevel-sep22.web.app/
Other
23 stars 3 forks source link

Windows+WSL2: `npm` process is very slow in Docker Compose #83

Closed akauppi closed 1 year ago

akauppi commented 2 years ago

Preparation:

   npm run dc:warm-up &&
   echo "[DEBUG] Warmed up, opening port 6768" &&

Steps:

$ docker compose up warm-up --abort-on-container-exit

Expectation:

Actual:

This means warmed-up times out, npm test doesn't work etc.

Docker Desktop for Windows 4.0.1

akauppi commented 2 years ago

Between Jest having written "Ran all the tests", and it returning the process to npm is where there's a WEIRD 30+ s pause on Windows+WSL2. It does eventually return. Likely some timeout within Jest, but which???

Docker Desktop for Windows 4.0.1 Jest 27.2.0 (also happens with 27.1.1)

Work-around for now: increased warm-up timeout to 2 min in DC.

akauppi commented 2 years ago

There still is the strange pause (next.jun22 branch).

$ LOGS_PATH=./logs FUNCTIONS_PORT=5002 docker compose up warm-up --abort-on-container-exit

..seems to start warm-up normally.

$ npm test

# 20s: "backend-warm-up-1 Started"
# 3m17s: tests start
# 3m30s: tests end; success

What goes on within that 3 min?

Once/if solved, reduce start_period in packages/backend/docker-compose.yml and remove a comment there.

Note: This only affects cold starts (all Docker containers are down).

akauppi commented 1 year ago
akauppi commented 1 year ago

The strange behaviour still seems to be there, though the above instructions no longer apply for reproduction.

Looks like a Jest exit timeout. (Jest 29.3.0)

akauppi commented 1 year ago

Adding --forceExit to the Jest flags helps. Note that --detectOpenHandles gives no indication what the problematic resources would be. likely keeping the work-around, because it makes for a better initial developer experience.

akauppi commented 1 year ago

The Jest issue is this.

Complex. The current gut feeling is, it has to do with firebase-prime and could be counteracted by the snippet in that issue here.

Immediate work-around

Adding --forceExit to the calling of the Jest works, cutting Jest process execution from 1:26s to 15s (measured by time preceding the Jest command). Tempting to leave it ... but solving it within the tests would be nicer!