Skip to content

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

Closed
@zzycn003

Description

@zzycn003

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions