Code Monkey home page Code Monkey logo

Comments (6)

ReneWerner87 avatar ReneWerner87 commented on May 21, 2024 2

ok, we will consider it for v3
and handle it better

from fiber.

gabrielmarinhoindico avatar gabrielmarinhoindico commented on May 21, 2024 1

simliar to our check

fiber/app.go

Lines 1094 to 1095 in 9b0a99b

case errors.Is(err, fasthttp.ErrBodyTooLarge):
err = ErrRequestEntityTooLarge

One thing that i noticed is that Params from ctx.Route().Params return an empty slice when this case happens, so to solve this internally before a possible update from fiber is to create a helper function, something like this:

func AllParams(c *fiber.Ctx) map[string]string {
	route := c.Route()

	if len(route.Params) == 0 {
		return nil
	}

	return c.AllParams()
}

Maybe help someone with the same problem.

from fiber.

welcome avatar welcome commented on May 21, 2024

Thanks for opening your first issue here! ๐ŸŽ‰ Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

from fiber.

ReneWerner87 avatar ReneWerner87 commented on May 21, 2024

interesting
i guess because body limit is an error which is handled on the fasthttp level and the parameters and routing comes after that

can you share the panic error

in this case, you probably have to check your own error handler for this error first and handle it without any further information

from fiber.

ReneWerner87 avatar ReneWerner87 commented on May 21, 2024

simliar to our check

fiber/app.go

Lines 1094 to 1095 in 9b0a99b

case errors.Is(err, fasthttp.ErrBodyTooLarge):
err = ErrRequestEntityTooLarge

from fiber.

gabrielmarinhoindico avatar gabrielmarinhoindico commented on May 21, 2024

interesting i guess because body limit is an error which is handled on the fasthttp level and the parameters and routing comes after that

can you share the panic error

in this case, you probably have to check your own error handler for this error first and handle it without any further information

If the allParams expect always have a value in route property instead of a nil value, this doesn't mean that the function maybe need a change to check if the route is nil or not? maybe in a v3 of fiber?

The panic:


"runtime error: invalid memory address or nil pointer dereference"
Stack:
	 4  0x0000000000af3319 in github.com/gofiber/fiber/v2.(*Ctx).AllParams
	     at /home/gabrielclaudinomarinho/go/pkg/mod/github.com/gofiber/fiber/[email protected]/ctx.go:1017
	 5  0x0000000001426625 in api.example/pkg/app.customErrorHandler
	     at /home/gabrielclaudinomarinho/projects/api.example/pkg/app/app.go:89
	 6  0x0000000000aea62d in github.com/gofiber/fiber/v2.(*App).ErrorHandler
	     at /home/gabrielclaudinomarinho/go/pkg/mod/github.com/gofiber/fiber/[email protected]/app.go:1061
	 7  0x0000000000aeab71 in github.com/gofiber/fiber/v2.(*App).serverErrorHandler
	     at /home/gabrielclaudinomarinho/go/pkg/mod/github.com/gofiber/fiber/[email protected]/app.go:1093
	 8  0x0000000000b1b7a5 in github.com/gofiber/fiber/v2.(*App).serverErrorHandler-fm
	     at <autogenerated>:1
	 9  0x0000000000a50f87 in github.com/valyala/fasthttp.(*Server).writeErrorResponse
	     at /home/gabrielclaudinomarinho/go/pkg/mod/github.com/valyala/[email protected]/server.go:2850
	10  0x0000000000a4d5c5 in github.com/valyala/fasthttp.(*Server).serveConn
	     at /home/gabrielclaudinomarinho/go/pkg/mod/github.com/valyala/[email protected]/server.go:2287
	11  0x0000000000a63c05 in github.com/valyala/fasthttp.(*Server).serveConn-fm
	     at <autogenerated>:1
	12  0x0000000000a5f077 in github.com/valyala/fasthttp.(*workerPool).workerFunc
	     at /home/gabrielclaudinomarinho/go/pkg/mod/github.com/valyala/[email protected]/workerpool.go:224
	13  0x0000000000a5eda5 in github.com/valyala/fasthttp.(*workerPool).getCh.func1
	     at /home/gabrielclaudinomarinho/go/pkg/mod/github.com/valyala/[email protected]/workerpool.go:196

from fiber.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.