mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-02-06 08:49:17 +00:00
updated modernc versions checks
This commit is contained in:
parent
f6407b903b
commit
07552c2809
@ -1,4 +1,4 @@
|
||||
## v0.23.12 (WIP)
|
||||
## v0.23.12
|
||||
|
||||
- Skipped the default body size limit middleware for the backup upload endpooint ([#6152](https://github.com/pocketbase/pocketbase/issues/6152)).
|
||||
|
||||
|
@ -4,6 +4,9 @@ import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"runtime/debug"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -15,7 +18,14 @@ const (
|
||||
ModerncDepsCheckHookId = "pbModerncDepsCheck"
|
||||
)
|
||||
|
||||
func checkModerncDeps(logger *slog.Logger) {
|
||||
// checkModerncDeps checks whether the current binary was buit with the
|
||||
// expected and tested modernc driver dependencies.
|
||||
//
|
||||
// This is needed because modernc.org/libc doesn't follow semantic versioning
|
||||
// and using a version different from the one in the go.mod of modernc.org/sqlite
|
||||
// could have unintended side-effects and cause obscure build and runtime bugs
|
||||
// (https://github.com/pocketbase/pocketbase/issues/6136).
|
||||
func checkModerncDeps(app core.App) {
|
||||
info, ok := debug.ReadBuildInfo()
|
||||
if !ok {
|
||||
return // no build info (probably compiled without module support)
|
||||
@ -42,23 +52,32 @@ func checkModerncDeps(logger *slog.Logger) {
|
||||
return
|
||||
}
|
||||
|
||||
var msg string
|
||||
if driverVersion != expectedDriverVersion {
|
||||
logger.Warn(fmt.Sprintf(
|
||||
"You are using modernc.org/sqlite %s which differs from the tested %s.\n"+
|
||||
msg = fmt.Sprintf(
|
||||
"You are using modernc.org/sqlite %s which differs from the expected and tested %s.\n"+
|
||||
"Make sure to either manually update in your go.mod the dependency version to the expected one OR if you want to keep yours "+
|
||||
"ensure that its indirect modernc.org/libc dependency has the same version as in the https://gitlab.com/cznic/sqlite/-/blob/master/go.mod, "+
|
||||
"otherwise it could result in unexpected build or runtime errors.",
|
||||
driverVersion,
|
||||
expectedDriverVersion,
|
||||
), slog.String("current", driverVersion), slog.String("expected", expectedDriverVersion))
|
||||
)
|
||||
app.Logger().Warn(msg, slog.String("current", driverVersion), slog.String("expected", expectedDriverVersion))
|
||||
} else if libcVersion != expectedLibcVersion {
|
||||
logger.Warn(fmt.Sprintf(
|
||||
"You are using a modernc.org/libc %s which differs from the tested %s.\n"+
|
||||
msg = fmt.Sprintf(
|
||||
"You are using modernc.org/libc %s which differs from the expected and tested %s.\n"+
|
||||
"Please update your go.mod and manually set modernc.org/libc to %s, otherwise it could result in unexpected build or runtime errors "+
|
||||
"(you may have to also run 'go clean -modcache' to clear the cache if the warning persists).",
|
||||
libcVersion,
|
||||
expectedLibcVersion,
|
||||
expectedLibcVersion,
|
||||
), slog.String("current", libcVersion), slog.String("expected", expectedLibcVersion))
|
||||
)
|
||||
app.Logger().Warn(msg, slog.String("current", libcVersion), slog.String("expected", expectedLibcVersion))
|
||||
}
|
||||
|
||||
// ensure that the message is printed to the default stderr too
|
||||
// (when in dev mode this is not needed because we print all logs)
|
||||
if msg != "" && !app.IsDev() {
|
||||
color.Yellow("\nWARN " + msg + "\n\n")
|
||||
}
|
||||
}
|
||||
|
@ -148,9 +148,9 @@ func NewWithConfig(config Config) *PocketBase {
|
||||
}
|
||||
|
||||
// run separately to avoid blocking
|
||||
logger := be.App.Logger()
|
||||
app := be.App
|
||||
routine.FireAndForget(func() {
|
||||
checkModerncDeps(logger)
|
||||
checkModerncDeps(app)
|
||||
})
|
||||
|
||||
return nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user