Nuxt “/_loading/sse” results in “ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK)”

Issue

In order to overcome CORS and TLS/SSL issues during Nuxt 2.14 project development, a Docker Nginx and Node containers are in use, where Nginx is also used as a reverse-proxy.

DevTools Console is currently indicating these regular request failures:

GET https://test.testpay.local:444/_loading/sse net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK) :444/_loading/sse:1

Nginx Proxy Container logs indicated the following issue:

test-dp-webserver  | 2024/05/24 12:45:07 [error] 235#235: *309 upstream timed out (110: Connection timed out) while reading upstream, client: 172.22.0.1, server: test.testpay.local, request: "GET /_loading/sse HTTP/1.1", upstream: "http://172.22.0.3:3000/_loading/sse", host: "test.testpay.local:444", referrer: "https://test.testpay.local:444/@5/payment"
test-dp-webserver  | 172.22.0.1 - - [24/May/2024:12:45:07 +0000] "GET /_loading/sse HTTP/1.1" 200 0 "https://test.testpay.local:444/@5/payment" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36" "-"
test-dp-webserver  | 2024/05/24 12:46:10 [error] 238#238: *319 upstream timed out (110: Connection timed out) while reading upstream, client: 172.22.0.1, server: test.testpay.local, request: "GET /_loading/sse HTTP/1.1", upstream: "http://172.22.0.3:3000/_loading/sse", host: "test.testpay.local:444", referrer: "https://test.testpay.local:444/@5/payment"
test-dp-webserver  | 172.22.0.1 - - [24/May/2024:12:46:10 +0000] "GET /_loading/sse HTTP/1.1" 200 0 "https://test.testpay.local:444/@5/payment" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36" "-"
test-dp-webserver  | 2024/05/24 12:47:13 [error] 235#235: *349 upstream timed out (110: Connection timed out) while reading upstream, client: 172.22.0.1, server: test.testpay.local, request: "GET /_loading/sse HTTP/1.1", upstream: "http://172.22.0.3:3000/_loading/sse", host: "test.testpay.local:444", referrer: "https://test.testpay.local:444/@5/payment"
test-dp-webserver  | 172.22.0.1 - - [24/May/2024:12:47:13 +0000] "GET /_loading/sse HTTP/1.1" 200 0 "https://test.testpay.local:444/@5/payment" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36" "-"
test-dp-webserver  | 2024/05/24 12:48:17 [error] 235#235: *351 upstream timed out (110: Connection timed out) while reading upstream, client: 172.22.0.1, server: test.testpay.local, request: "GET /_loading/sse HTTP/1.1", upstream: "http://172.22.0.3:3000/_loading/sse", host: "test.testpay.local:444", referrer: "https://test.testpay.local:444/@5/payment"
test-dp-webserver  | 172.22.0.1 - - [24/May/2024:12:48:17 +0000] "GET /_loading/sse HTTP/1.1" 200 0 "https://test.testpay.local:444/@5/payment" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36" "-"

Environment

Nginx configuration is the following:

upstream nuxt {
    ip_hash;

    server test-node:3000;
}

server {
  server_name 'test.testpay.local';

  listen 443 ssl;

  include '/etc/nginx/mime.types';

  # SSL
  # --------------------------------

  include './conf.d/tls/main.conf';
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;

  # Proxy
  # --------------------------------

  proxy_next_upstream error;

  # Locations
  # ----------------------------------------------------------------

  location / {
    proxy_set_header Host               '$host';
    proxy_set_header X-Real-IP          '$remote_addr';
    proxy_set_header X-Forwarded-For    '$proxy_add_x_forwarded_for';
    proxy_set_header X-Forwarded-Proto  '$scheme';

    proxy_pass http://nuxt;
  }
}

Question

What might it be? Is it expected or how would you debug the connection/cause deeper?

After some investigation, it appears to be a misconfiguration between proxy and Nuxt SSE (i.e. Loading Screen Module for Nuxt.js).

Content-Type: text/event-stream header received from the module required a continuous connection for Server-Sent Events or SSE to work, and proxy was terminating connection too soon where no message was sent from the Nuxt end.

An increase of the default 60s (as of 2024-05) Nginx setting proxy read timeout to something longer like 3600s solved the issue. In this case, we expect the Nuxt end to send anything within that limit to the client.

In other words, the following changes should be done in the above Nginx reverse-proxy configuration:

location / {
  proxy_set_header Host               '$host';
  proxy_set_header X-Real-IP          '$remote_addr';
  proxy_set_header X-Forwarded-For    '$proxy_add_x_forwarded_for';
  proxy_set_header X-Forwarded-Proto  '$scheme';

  proxy_read_timeout 3600;

  proxy_pass http://nuxt;
}

Et voila!


However, it’s worth to mention:

  1. Nginx setting proxy_buffering off; may be required, too, since it was recommended in this answer, yet I had no issues without it set.

The Chrome browser will kill an inactive stream after two minutes of inactivity. If
you want to keep it alive, you need to add some code to send something from the server to the browser at least once every two minutes.

Source

Related

  1. Why do I get many SSE request that slow down my webpage in my NUXT.js project?…
  2. Getting net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 when consuming event-stream…
  3. Chrome net::ERR_INCOMPLETE_CHUNKED_ENCODING error…

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật