Skip to content

🐛 [Bug]: v3 Flash messages are never cleared #3933

@mrusme

Description

@mrusme

Bug Description

It appears that despite issuing messages := c.Redirect().Messages(), the flash messages are never cleared and hence keep re-appearing on every page reload and even on other pages that also check for flash messages.

CC: #3455 (comment)

How to Reproduce

Steps to reproduce the behavior:

  1. Set flash messages:
func (req *Request) redirect(url string) (err error) {
	redir := req.c.Redirect()
	for key, msg := range AllMyFlashMessages() {
		redir = redir.With(key, msg)
	}
	return redir.To(url)
}
  1. Request the flash messages inside a handler and display them on the page
  2. Trigger flash messages to be set
  3. Load any page displaying the flash messages

Expected Behavior

After issuing messages := c.Redirect().Messages() the flash messages should be gone. You can validate that this is not the case simply by issuing that line of code two times, one after the other. Both will return messages.

Fiber Version

v3

Code Snippet (optional)

Checklist:

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions