Khez
Repos
33
Followers
2
Following
1

Events

issue comment
🐛 [Bug]: Logger bytesSent incompatible with SSE

When streaming you are using Transfer-Encoding: chunked, which makes Content-Length: -1.

https://github.com/valyala/fasthttp/blob/master/header.go#L236

Created at 2 months ago
fork
Created at 2 months ago
opened issue
🐛 [Bug]: Logger bytesSent incompatible with SSE

Bug Description

After activating bytesSent on the logger, all SSE endpoints stop streaming.

It most likely caused by the logger attempting to read the full body length, consuming data before it is sent the client.

https://github.com/gofiber/fiber/blob/master/middleware/logger/tags.go#L91

How to Reproduce

Steps to reproduce the behavior:

  1. Follow the instructions on https://github.com/gofiber/recipes/tree/master/sse
  2. Check SSE route, confirm it streams
  3. Add logger middleware https://docs.gofiber.io/api/middleware/logger
  4. Add sure the format contains ${bytesSent} as shown under https://docs.gofiber.io/api/middleware/logger#constants
  5. Check SSE route again, confirm it stops streaming

Expected Behavior

SSE Should continue streaming.

Fiber Version

2.40.1

Code Snippet (optional)

// @see https://github.com/gofiber/recipes/tree/master/sse
// @see https://docs.gofiber.io/api/middleware/logger#constants

Checklist:

  • [X] I agree to follow Fiber's Code of Conduct.
  • [X] I have checked for existing issues that describe my problem prior to opening this one.
  • [X] I understand that improperly formatted bug reports may be closed without explanation.
Created at 2 months ago
Created at 2 months ago