Skip to content

Request hangs with 100% CPU usage when route has a path param and URL is terminated with "/" #1510

Closed
@gnyekhelyi

Description

@gnyekhelyi

Issue Description

Request hangs (no response), the server process has 100% CPU usage when route has a path parameter (e.g.: "/users/:id") and URL is terminated with "/"

Checklist

  • Dependencies installed
  • No typos
  • Searched existing issues and docs

Expected behaviour

404 error

Actual behaviour

Request hangs, causing the server process to use 100% CPU

Steps to reproduce

curl localhost:8080/users/123/

Working code to debug

package main

import (
	"github.com/labstack/echo/v4"
	"net/http"
)

func main() {
	e := echo.New()
	e.GET("/users/:id", func(c echo.Context) error {
		id := c.Param("id")
		return c.String(http.StatusOK, "id=" + id)
	})
	e.Logger.Fatal(e.Start(": 8080"))
}

Version/commit

v4.1.14

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions