You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to permanently avoid the problem of #2396, we should start and switch to never return anonymous functions (closures) but return non-anonymous functions instead so no data is shared — never. For middlewares this might look as follows:
// New creates a new middleware handlerfuncNew(config...Config) fiber.Handler {
// Setup, etc.// Return new handlerreturnnewHandler(list, shared, data, here, config, etc)
}
funcnewHandler(list, shared, data, here, config, etc) func(c*fiber.Ctx) {
// Important: Never do anything in here before returning the closure.returnfunc(c*fiber.Ctx) {
// Code of handler as before, but without access to data of setup logic
}
}
we should definitely check the benchmarks afterwards to make sure that the allocations have remained identical.
Since the framework is trimmed for speed, this has priority over possible error prevention in this case.
but hope this should not conflict at all and of course works without changing the memory accesses
In order to permanently avoid the problem of #2396, we should start and switch to never return anonymous functions (closures) but return non-anonymous functions instead so no data is shared — never. For middlewares this might look as follows:
Originally posted by @leonklingele in #2396 (comment)
The text was updated successfully, but these errors were encountered: