You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "rusackas (via GitHub)" <gi...@apache.org> on 2026/02/22 05:51:43 UTC

[PR] fix(docker): prevent static asset 404s by waiting for webpack dev server [superset]

rusackas opened a new pull request, #38161:
URL: https://github.com/apache/superset/pull/38161

   ### SUMMARY
   
   Fixes a race condition in the Docker development setup where nginx starts before the webpack dev server is ready, causing 404 errors for all static assets (`/static/assets/images/superset-logo-horiz.png`, etc.).
   
   **Root Cause:**
   When running `docker compose up`, nginx starts immediately and proxies `/static` requests to port 9000. However, the `superset-node` container needs time to:
   1. Run `npm install` (can take several minutes)
   2. Start the webpack dev server
   
   During this startup period, all static asset requests fail with 404 errors.
   
   **The Fix:**
   1. Added a health check to `superset-node` that verifies the webpack dev server is responding on port 9000
   2. Added `depends_on: superset-node: condition: service_healthy` to nginx so it waits for the frontend to be ready
   
   The health check uses Node.js (already in the container) to make HTTP requests, with a 60-second start period and up to 30 retries at 10-second intervals (5+ minutes total wait time).
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   **Before:** Static assets return 404 during startup, broken UI
   **After:** Nginx waits for webpack dev server to be healthy before starting
   
   ### TESTING INSTRUCTIONS
   
   1. Clean your Docker environment:
      ```bash
      docker compose down -v
      docker builder prune --all --force
      ```
   
   2. Start fresh:
      ```bash
      docker compose up
      ```
   
   3. Watch the logs - you should see:
      - `superset-node` running `npm install` and starting dev server
      - nginx waiting (health check retrying)
      - nginx starting only after `superset-node` is healthy
   
   4. Access http://localhost - static assets should load correctly
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: Fixes #30183
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   🤖 Generated with [Claude Code](https://claude.ai/code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(docker): prevent static asset 404s by waiting for webpack dev server [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on PR #38161:
URL: https://github.com/apache/superset/pull/38161#issuecomment-3940238446

   <!-- Answer -->
   **Related Documentation**
   
   Checked 0 published document(s) in 2 knowledge base(s). No updates required.
   
   
   <!-- Dosu Comment Footer -->
   <sup>How did I do? Any feedback?</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(docker): prevent static asset 404s by waiting for webpack dev server [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #38161:
URL: https://github.com/apache/superset/pull/38161#discussion_r3126449730


##########
docker-compose.yml:
##########
@@ -61,6 +61,9 @@ services:
     volumes:
       - ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
       - ./docker/nginx/templates:/etc/nginx/templates:ro
+    depends_on:
+      superset-node:
+        condition: service_healthy

Review Comment:
   Good catch — went with option (b) in 014bca8. The wait loop now lives in the nginx container (curl-polls `host.docker.internal:9000/static/assets/manifest.json` before exec'ing nginx), so it works whether the dev server runs inside `superset-node` or on the host. Dropped the `superset-node` healthcheck and the `service_healthy` gate since they're no longer needed.



##########
docker-compose.yml:
##########
@@ -186,6 +189,14 @@ services:
       - path: docker/.env-local # optional override
         required: false
     volumes: *superset-volumes
+    healthcheck:
+      # Check if webpack dev server is responding on port 9000
+      # This prevents nginx from proxying before the frontend is ready
+      test: ["CMD-SHELL", "node -e \"const http = require('http'); http.get('http://localhost:9000', (r) => process.exit(r.statusCode === 200 ? 0 : 1)).on('error', () => process.exit(1))\""]

Review Comment:
   Agreed — fixed in 014bca8. The probe now hits `/static/assets/manifest.json` (served directly by webpack's devMiddleware at `publicPath: '/static/assets/'`, and only written after the first compile, which is exactly the signal we want) instead of `/` (which the proxy config forwards to the backend). Also moved the probe out of a `superset-node` healthcheck and into an nginx-side wait loop so it works regardless of where the dev server runs.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(docker): prevent static asset 404s by waiting for webpack dev server [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #38161:
URL: https://github.com/apache/superset/pull/38161#discussion_r3364258591


##########
docker-compose.yml:
##########
@@ -61,6 +61,22 @@ services:
     volumes:
       - ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
       - ./docker/nginx/templates:/etc/nginx/templates:ro
+    # Wait for the webpack dev server's manifest.json to be served before
+    # starting nginx. This prevents 404s on static assets at startup. The
+    # probe targets host.docker.internal so it works regardless of whether
+    # the dev server runs in the superset-node container
+    # (BUILD_SUPERSET_FRONTEND_IN_DOCKER=true, the default) or directly on
+    # the host (BUILD_SUPERSET_FRONTEND_IN_DOCKER=false).
+    command:
+      - /bin/bash
+      - -c
+      - |
+        echo "Waiting for webpack dev server at host.docker.internal:9000/static/assets/manifest.json..."
+        until curl -sf -o /dev/null http://host.docker.internal:9000/static/assets/manifest.json; do

Review Comment:
   Good call — addressed in cf7a9cc. The wait loop now caps at ~5 minutes (150 attempts at 2s) and exits non-zero with a diagnostic message pointing at the likely cause (dev server not running, e.g. when `BUILD_SUPERSET_FRONTEND_IN_DOCKER=false` and it wasn't started on the host). I also added `curl --max-time 5` so a stalled connection can't block a single attempt indefinitely.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(docker): prevent static asset 404s by waiting for webpack dev server [superset]

Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on code in PR #38161:
URL: https://github.com/apache/superset/pull/38161#discussion_r3362529797


##########
docker-compose.yml:
##########
@@ -61,6 +61,22 @@ services:
     volumes:
       - ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
       - ./docker/nginx/templates:/etc/nginx/templates:ro
+    # Wait for the webpack dev server's manifest.json to be served before
+    # starting nginx. This prevents 404s on static assets at startup. The
+    # probe targets host.docker.internal so it works regardless of whether
+    # the dev server runs in the superset-node container
+    # (BUILD_SUPERSET_FRONTEND_IN_DOCKER=true, the default) or directly on
+    # the host (BUILD_SUPERSET_FRONTEND_IN_DOCKER=false).
+    command:
+      - /bin/bash
+      - -c
+      - |
+        echo "Waiting for webpack dev server at host.docker.internal:9000/static/assets/manifest.json..."
+        until curl -sf -o /dev/null http://host.docker.internal:9000/static/assets/manifest.json; do

Review Comment:
   **MEDIUM** — no timeout or retry ceiling on this wait loop. If the webpack dev server never comes up (failed `npm install`, build error, or forgotten start when `BUILD_SUPERSET_FRONTEND_IN_DOCKER=false`), nginx hangs indefinitely and is indistinguishable from normal waiting. Adding `--max-time N` to `curl` and/or a counter with a diagnostic exit message would make failures easier to diagnose. Non-blocking for a dev-only tool, but worth a follow-up.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(docker): prevent static asset 404s by waiting for webpack dev server [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #38161:
URL: https://github.com/apache/superset/pull/38161#discussion_r3126451645


##########
docker-compose.yml:
##########
@@ -186,6 +189,14 @@ services:
       - path: docker/.env-local # optional override
         required: false
     volumes: *superset-volumes
+    healthcheck:
+      # Check if webpack dev server is responding on port 9000
+      # This prevents nginx from proxying before the frontend is ready
+      test: ["CMD-SHELL", "node -e \"const http = require('http'); http.get('http://localhost:9000', (r) => process.exit(r.statusCode === 200 ? 0 : 1)).on('error', () => process.exit(1))\""]
+      interval: 10s
+      timeout: 5s
+      retries: 30
+      start_period: 60s

Review Comment:
   You were right — the previous approach would have broken `BUILD_SUPERSET_FRONTEND_IN_DOCKER=false` because `docker-frontend.sh` exits immediately in that mode, so the container could never become healthy and nginx would never start. Rather than deprecate the flag, I restructured the fix in 014bca8 to preserve it: the wait loop now lives in the nginx container and polls `host.docker.internal:9000/static/assets/manifest.json`, which works whether the dev server runs inside the node container (via the port mapping) or directly on the host. No changes to `docker-frontend.sh`, no breaking change, no docs/UPDATING.md update needed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(docker): prevent static asset 404s by waiting for webpack dev server [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #38161:
URL: https://github.com/apache/superset/pull/38161


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(docker): prevent static asset 404s by waiting for webpack dev server [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #38161:
URL: https://github.com/apache/superset/pull/38161#issuecomment-3940238455

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(docker): prevent static asset 404s by waiting for webpack dev server [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #38161:
URL: https://github.com/apache/superset/pull/38161#issuecomment-4633878427

   @aminghadersohi Thanks for the thorough review! Updated the PR description to match the nginx-side curl wait loop (it still described the old `superset-node` healthcheck + `service_healthy` approach). Also addressed your wait-loop timeout note in cf7a9cc — it now caps at ~5 minutes and exits with a diagnostic instead of hanging.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(docker): prevent static asset 404s by waiting for webpack dev server [superset]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #38161:
URL: https://github.com/apache/superset/pull/38161#discussion_r2885405703


##########
docker-compose.yml:
##########
@@ -186,6 +189,14 @@ services:
       - path: docker/.env-local # optional override
         required: false
     volumes: *superset-volumes
+    healthcheck:
+      # Check if webpack dev server is responding on port 9000
+      # This prevents nginx from proxying before the frontend is ready
+      test: ["CMD-SHELL", "node -e \"const http = require('http'); http.get('http://localhost:9000', (r) => process.exit(r.statusCode === 200 ? 0 : 1)).on('error', () => process.exit(1))\""]

Review Comment:
   The healthcheck probes `http://localhost:9000/` and requires a `200` response. In this repo the webpack dev server proxies most paths (including `/`) to the backend (see `superset-frontend/webpack.proxy-config.js`), so this endpoint commonly returns a redirect (e.g. `302` to `/login`) or may be blocked on backend readiness, causing the container to stay `unhealthy` and `nginx` to never start. Probe an asset endpoint served directly by webpack (e.g. `/static/assets/manifest.json`) and/or treat any 2xx/3xx as healthy.
   ```suggestion
         # Check if webpack dev server is serving static assets on port 9000
         # This prevents nginx from proxying before the frontend is ready
         test: ["CMD-SHELL", "node -e \"const http = require('http'); http.get('http://localhost:9000/static/assets/manifest.json', (r) => process.exit(r.statusCode >= 200 && r.statusCode < 400 ? 0 : 1)).on('error', () => process.exit(1))\""]
   ```



##########
docker-compose.yml:
##########
@@ -61,6 +61,9 @@ services:
     volumes:
       - ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
       - ./docker/nginx/templates:/etc/nginx/templates:ro
+    depends_on:
+      superset-node:
+        condition: service_healthy

Review Comment:
   `nginx` now waits on `superset-node` being *healthy*. However, `docker/docker-frontend.sh` exits immediately when `BUILD_SUPERSET_FRONTEND_IN_DOCKER=false` (a supported workflow per the comment in this service), which means `superset-node` will never become healthy and `nginx` will never start. Consider either (a) keeping `superset-node` running even in the "skip" mode and making its healthcheck validate the externally-run dev server, or (b) moving the waiting logic into the `nginx` container (entrypoint wait loop) so the setup still works when the dev server is run on the host.
   ```suggestion
           condition: service_started
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(docker): prevent static asset 404s by waiting for webpack dev server [superset]

Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #38161:
URL: https://github.com/apache/superset/pull/38161#issuecomment-4299409572

   ### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">🔨</span> Latest commit | 014bca8eea8ba888348ea4fdf56ce278cfeafbde |
   |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/69e9215827d70b0008c3b4ec |
   |<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-38161--superset-docs-preview.netlify.app](https://deploy-preview-38161--superset-docs-preview.netlify.app) |
   |<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />![QR Code](https://app.netlify.com/qr-code/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTM4MTYxLS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ.yQLJ5RuH9Jki6nfODar1Vbeg_wsHtUPZEAfGsVkEajE)<br /><br />_Use your smartphone camera to open QR code link._</details> |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-38161--superset-docs-preview.netlify.app) -->
   _To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(docker): prevent static asset 404s by waiting for webpack dev server [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #38161:
URL: https://github.com/apache/superset/pull/38161#issuecomment-4636672098

   **Bito Automatic Review Skipped – PR Already Merged**<br/><br/>Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.<br/>No action is needed if you didn't intend to review it. To get a review, you can type `/review` in a comment and save it


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(docker): prevent static asset 404s by waiting for webpack dev server [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #38161:
URL: https://github.com/apache/superset/pull/38161#issuecomment-4634464332

   @aminghadersohi Thanks! Good catch on the description drift — I went back and updated the PR body so it now describes the nginx-side curl wait loop (polling `host.docker.internal:9000/static/assets/manifest.json` with the ~5min cap and `--max-time 5`) rather than the old `superset-node` healthcheck + `depends_on: service_healthy` approach. Should match the implementation now.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org