Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

superfluous response.WriteHeader call from github.com/labstack/echo/v4/middleware.TimeoutWithConfig.func1.1 (timeout.go:70) #1905

Closed
zzycn003 opened this issue Jul 1, 2021 · 1 comment

Comments

@zzycn003
Copy link

zzycn003 commented Jul 1, 2021

Issue Description

Timeout middleware always log superfluous response.WriteHeader for a not existed route(404.

Steps to reproduce

access a not existed url like http://localhost:8080/bla

Working code to debug

package main

import (
	"log"
	"net/http"
	"time"

	"github.com/labstack/echo/v4"
	"github.com/labstack/echo/v4/middleware"
)

func main() {
	e := echo.New()
	// add middleware and routes
	// ...

	e.Use(middleware.TimeoutWithConfig(middleware.TimeoutConfig{
		ErrorMessage: "request timeout, please retry later.",
		Timeout:      30 * time.Second,
	}))

	e.GET("/ping", func(c echo.Context) error {
		return c.String(200, "pong")
	})

	if err := e.Start(":8080"); err != http.ErrServerClosed {
		log.Fatal(err)
	}
}

Version/commit

github.com/labstack/echo/v4 v4.3.0

@pwli0755
Copy link
Contributor

pwli0755 commented Aug 2, 2021

This bug is a little tricky, if we use the http.TimeoutHandler implementation, we probably lost some precise control.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants