[GH-ISSUE #1815] Web server not responding to graceful shutdown #1133

Open
opened 2026-03-02 11:55:15 +03:00 by kerem · 2 comments
Owner

Originally created by @RivalManiac on GitHub (Aug 3, 2025).
Original GitHub issue: https://github.com/karakeep-app/karakeep/issues/1815

Describe the Bug

When running docker compose down karakeep-web will timeout no matter how long of a timeout is provided. Both chrome and search shutdown in less then 2 seconds but the web portion only stops once the SIGKILL command is sent by docker, preventing any graceful shutdown.

Steps to Reproduce

  1. Docker compose up -d with provided compose.yml (except running as user 1000 instead of root)
  2. Docker compose down --timeout 60
  3. Web container reaches full timeout before being killed

Expected Behaviour

Container shuts down gracefully in the allotted time.

Screenshots or Additional Context

The logs when the shutdown command is sent by docker compose down:

docker logs karakeep
/package/admin/s6-overlay/libexec/preinit: info: /run belongs to uid 0 instead of 1000 - fixing it
s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service init-db-migration: starting
Running db migration script
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service init-db-migration successfully started
s6-rc: info: service svc-workers: starting
s6-rc: info: service svc-web: starting
s6-rc: info: service svc-workers successfully started
s6-rc: info: service svc-web successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
▲ Next.js 14.2.25

✓ Starting...
✓ Ready in 165ms
2025-08-03T18:08:52.892Z info: Workers version: 0.26.0
2025-08-03T18:08:52.897Z info: [crawler] Loading adblocker ...
2025-08-03T18:08:53.956Z info: [Crawler] Connecting to existing browser instance: http://chrome:9222
2025-08-03T18:08:53.957Z info: [Crawler] Successfully resolved IP address, new address: http://192.168.48.2:9222/
2025-08-03T18:08:54.007Z info: Starting crawler worker ...
2025-08-03T18:08:54.007Z info: Starting inference worker ...
2025-08-03T18:08:54.007Z info: Starting search indexing worker ...
2025-08-03T18:08:54.007Z info: Starting tidy assets worker ...
2025-08-03T18:08:54.007Z info: Starting video worker ...
2025-08-03T18:08:54.007Z info: Starting feed worker ...
2025-08-03T18:08:54.007Z info: Starting asset preprocessing worker ...
2025-08-03T18:08:54.007Z info: Starting webhook worker ...
2025-08-03T18:08:54.007Z info: Starting rule engine worker ...
<-- GET /api/health
--> GET /api/health 200 2ms
2025-08-03T18:09:20.317Z info: [Crawler] The Playwright browser got disconnected. Will attempt to launch it again.
2025-08-03T18:09:20.317Z info: [Crawler] Connecting to existing browser instance: http://chrome:9222
2025-08-03T18:09:20.319Z info: [Crawler] Successfully resolved IP address, new address: http://192.168.48.2:9222/
2025-08-03T18:09:20.321Z error: [Crawler] Failed to connect to the browser instance, will retry in 5 secs: browserType.connectOverCDP: connect ECONNREFUSED 192.168.48.2:9222
Call log:

  • retrieving websocket url from http://192.168.48.2:9222/

    at Proxy.connectOverCDP (/app/apps/workers/node_modules/.pnpm/playwright-extra@4.3.6_playwright-core@1.53.1_playwright@1.53.1/node_modules/playwright-extra/dist/index.cjs.js:772:63)
    at async startBrowserInstance (/app/apps/workers/dist/index.mjs:55277:10)
    at async file:///app/apps/workers/dist/index.mjs:55290:20
    2025-08-03T18:09:25.322Z info: [Crawler] Connecting to existing browser instance: http://chrome:9222
    2025-08-03T18:09:25.323Z error: [Crawler] Failed to connect to the browser instance, will retry in 5 secs: Error: getaddrinfo ENOTFOUND chrome
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:internal/dns/promises:88:17)
    at GetAddrInfoReqWrap.callbackTrampoline (node:internal/async_hooks:130:17)
    <-- GET /api/health
    --> GET /api/health 200 1ms

Device Details

No response

Exact Karakeep Version

v0.26.0

Have you checked the troubleshooting guide?

  • I have checked the troubleshooting guide and I haven't found a solution to my problem
Originally created by @RivalManiac on GitHub (Aug 3, 2025). Original GitHub issue: https://github.com/karakeep-app/karakeep/issues/1815 ### Describe the Bug When running docker compose down karakeep-web will timeout no matter how long of a timeout is provided. Both chrome and search shutdown in less then 2 seconds but the web portion only stops once the SIGKILL command is sent by docker, preventing any graceful shutdown. ### Steps to Reproduce 1. Docker compose up -d with provided compose.yml (except running as user 1000 instead of root) 2. Docker compose down --timeout 60 3. Web container reaches full timeout before being killed ### Expected Behaviour Container shuts down gracefully in the allotted time. ### Screenshots or Additional Context The logs when the shutdown command is sent by docker compose down: docker logs karakeep /package/admin/s6-overlay/libexec/preinit: info: /run belongs to uid 0 instead of 1000 - fixing it s6-rc: info: service s6rc-oneshot-runner: starting s6-rc: info: service s6rc-oneshot-runner successfully started s6-rc: info: service fix-attrs: starting s6-rc: info: service init-db-migration: starting Running db migration script s6-rc: info: service fix-attrs successfully started s6-rc: info: service legacy-cont-init: starting s6-rc: info: service legacy-cont-init successfully started s6-rc: info: service init-db-migration successfully started s6-rc: info: service svc-workers: starting s6-rc: info: service svc-web: starting s6-rc: info: service svc-workers successfully started s6-rc: info: service svc-web successfully started s6-rc: info: service legacy-services: starting s6-rc: info: service legacy-services successfully started ▲ Next.js 14.2.25 - Local: http://localhost:3000 - Network: http://0.0.0.0:3000 ✓ Starting... ✓ Ready in 165ms 2025-08-03T18:08:52.892Z info: Workers version: 0.26.0 2025-08-03T18:08:52.897Z info: [crawler] Loading adblocker ... 2025-08-03T18:08:53.956Z info: [Crawler] Connecting to existing browser instance: http://chrome:9222 2025-08-03T18:08:53.957Z info: [Crawler] Successfully resolved IP address, new address: http://192.168.48.2:9222/ 2025-08-03T18:08:54.007Z info: Starting crawler worker ... 2025-08-03T18:08:54.007Z info: Starting inference worker ... 2025-08-03T18:08:54.007Z info: Starting search indexing worker ... 2025-08-03T18:08:54.007Z info: Starting tidy assets worker ... 2025-08-03T18:08:54.007Z info: Starting video worker ... 2025-08-03T18:08:54.007Z info: Starting feed worker ... 2025-08-03T18:08:54.007Z info: Starting asset preprocessing worker ... 2025-08-03T18:08:54.007Z info: Starting webhook worker ... 2025-08-03T18:08:54.007Z info: Starting rule engine worker ... <-- GET /api/health --> GET /api/health 200 2ms 2025-08-03T18:09:20.317Z info: [Crawler] The Playwright browser got disconnected. Will attempt to launch it again. 2025-08-03T18:09:20.317Z info: [Crawler] Connecting to existing browser instance: http://chrome:9222 2025-08-03T18:09:20.319Z info: [Crawler] Successfully resolved IP address, new address: http://192.168.48.2:9222/ 2025-08-03T18:09:20.321Z error: [Crawler] Failed to connect to the browser instance, will retry in 5 secs: browserType.connectOverCDP: connect ECONNREFUSED 192.168.48.2:9222 Call log: - <ws preparing> retrieving websocket url from http://192.168.48.2:9222/ at Proxy.connectOverCDP (/app/apps/workers/node_modules/.pnpm/playwright-extra@4.3.6_playwright-core@1.53.1_playwright@1.53.1/node_modules/playwright-extra/dist/index.cjs.js:772:63) at async startBrowserInstance (/app/apps/workers/dist/index.mjs:55277:10) at async file:///app/apps/workers/dist/index.mjs:55290:20 2025-08-03T18:09:25.322Z info: [Crawler] Connecting to existing browser instance: http://chrome:9222 2025-08-03T18:09:25.323Z error: [Crawler] Failed to connect to the browser instance, will retry in 5 secs: Error: getaddrinfo ENOTFOUND chrome at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:internal/dns/promises:88:17) at GetAddrInfoReqWrap.callbackTrampoline (node:internal/async_hooks:130:17) <-- GET /api/health --> GET /api/health 200 1ms ### Device Details _No response_ ### Exact Karakeep Version v0.26.0 ### Have you checked the troubleshooting guide? - [x] I have checked the troubleshooting guide and I haven't found a solution to my problem
Author
Owner

@MohamedBassem commented on GitHub (Sep 7, 2025):

I can't seem to repro:

Start a container:

❯❯❯ docker run --rm -e NEXTAUTH_SECRET=1234  ghcr.io/karakeep-app/karakeep:latest

Issue a docker stop with a 60 seconds timeout:

❯❯❯ time docker stop 92fd69be0f69 -t 60                                                                                                                                                                                                                                                                                     ✘ 130 main
92fd69be0f69
docker stop 92fd69be0f69 -t 60  0.01s user 0.01s system 0% cpu 3.275 total

The container exits in less than a second and you can see the graceful shutdown logs:

s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service svc-workers: stopping
s6-rc: info: service svc-web: stopping
2025-09-07T11:33:11.665Z info: Received SIGTERM, shutting down ...
2025-09-07T11:33:11.666Z info: Shutting down crawler, inference, tidyAssets, video, feed, assetPreprocessing, webhook, ruleEngine and search workers ...
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service svc-workers successfully stopped
s6-rc: info: service svc-web successfully stopped
s6-rc: info: service init-db-migration: stopping
s6-rc: info: service init-db-migration successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped
<!-- gh-comment-id:3263710194 --> @MohamedBassem commented on GitHub (Sep 7, 2025): I can't seem to repro: Start a container: ``` ❯❯❯ docker run --rm -e NEXTAUTH_SECRET=1234 ghcr.io/karakeep-app/karakeep:latest ``` Issue a docker stop with a 60 seconds timeout: ``` ❯❯❯ time docker stop 92fd69be0f69 -t 60 ✘ 130 main 92fd69be0f69 docker stop 92fd69be0f69 -t 60 0.01s user 0.01s system 0% cpu 3.275 total ``` The container exits in less than a second and you can see the graceful shutdown logs: ``` s6-rc: info: service legacy-services: stopping s6-rc: info: service legacy-services successfully stopped s6-rc: info: service legacy-cont-init: stopping s6-rc: info: service svc-workers: stopping s6-rc: info: service svc-web: stopping 2025-09-07T11:33:11.665Z info: Received SIGTERM, shutting down ... 2025-09-07T11:33:11.666Z info: Shutting down crawler, inference, tidyAssets, video, feed, assetPreprocessing, webhook, ruleEngine and search workers ... s6-rc: info: service legacy-cont-init successfully stopped s6-rc: info: service fix-attrs: stopping s6-rc: info: service fix-attrs successfully stopped s6-rc: info: service svc-workers successfully stopped s6-rc: info: service svc-web successfully stopped s6-rc: info: service init-db-migration: stopping s6-rc: info: service init-db-migration successfully stopped s6-rc: info: service s6rc-oneshot-runner: stopping s6-rc: info: service s6rc-oneshot-runner successfully stopped ```
Author
Owner

@RivalManiac commented on GitHub (Sep 24, 2025):

It appears that one of the recent updates fixed this. It used to timeout and force a kill no matter what time was set. However it stopped in under 3 seconds today with the docker compose down command.

<!-- gh-comment-id:3330811832 --> @RivalManiac commented on GitHub (Sep 24, 2025): It appears that one of the recent updates fixed this. It used to timeout and force a kill no matter what time was set. However it stopped in under 3 seconds today with the docker compose down command.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/karakeep#1133
No description provided.