diff --git a/main.go b/main.go index d66ffd06c94bc3b8c04abf58c59d40751087383b..35f92bba0dbfab857c64917e1558a4eb9612ce6b 100644 --- a/main.go +++ b/main.go @@ -249,7 +249,8 @@ func dbConnect(multiLogger *zap.Logger, config server.Config) (*sql.DB, string) multiLogger.Fatal("Error connecting to database", zap.Error(err)) } // Limit the time allowed to ping database and get version to 15 seconds total. - ctx, _ := context.WithTimeout(context.Background(), 15*time.Second) + ctx, ctxCancelFn := context.WithTimeout(context.Background(), 15*time.Second) + defer ctxCancelFn() if err = db.PingContext(ctx); err != nil { if strings.HasSuffix(err.Error(), "does not exist (SQLSTATE 3D000)") { multiLogger.Fatal("Database schema not found, run `nakama migrate up`", zap.Error(err)) diff --git a/server/api_test.go b/server/api_test.go index 21b7beafa36aa9ce85bf8b6e4b017e99deb66753..1b3a1ea9371cf88a5f47302c76a95d8ee801c3cd 100644 --- a/server/api_test.go +++ b/server/api_test.go @@ -166,7 +166,7 @@ func NewAPIServer(t *testing.T, runtime *Runtime) (*ApiServer, *Pipeline) { db := NewDB(t) router := &DummyMessageRouter{} tracker := &LocalTracker{} - pipeline := NewPipeline(logger, cfg, db, jsonpbMarshaler, jsonpbUnmarshaler, nil, nil, nil, tracker, router, runtime) + pipeline := NewPipeline(logger, cfg, db, jsonpbMarshaler, jsonpbUnmarshaler, nil, nil, nil, nil, tracker, router, runtime) apiServer := StartApiServer(logger, logger, db, jsonpbMarshaler, jsonpbUnmarshaler, cfg, nil, nil, nil, nil, nil, nil, tracker, router, metrics, pipeline, runtime) return apiServer, pipeline } diff --git a/server/console_authenticate.go b/server/console_authenticate.go index 1ec13116da8a64926cff8cc565718d8a37408175..f552f5f6b3e19e5127c33203a87014cb02931977 100644 --- a/server/console_authenticate.go +++ b/server/console_authenticate.go @@ -29,7 +29,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - jwt "github.com/dgrijalva/jwt-go" + "github.com/dgrijalva/jwt-go" "github.com/heroiclabs/nakama/v3/console" ) @@ -38,7 +38,7 @@ type ConsoleTokenClaims struct { Email string `json:"ema,omitempty"` Role console.UserRole `json:"rol,omitempty"` ExpiresAt int64 `json:"exp,omitempty"` - Cookie string `json:"cki,omitempty""` + Cookie string `json:"cki,omitempty"` } func (stc *ConsoleTokenClaims) Valid() error { diff --git a/server/runtime_lua_match_core.go b/server/runtime_lua_match_core.go index 75d14172399feb0487a15e92b7852ee7d3bcb34a..676212f3f179974c03a652e3dfdfd5d7159bfbd8 100644 --- a/server/runtime_lua_match_core.go +++ b/server/runtime_lua_match_core.go @@ -111,6 +111,7 @@ func NewRuntimeLuaMatchCore(logger *zap.Logger, module string, db *sql.DB, jsonp if apiErr, ok := err.(*lua.ApiError); ok { if strings.Contains(apiErr.Error(), fmt.Sprintf("module %s not found", name)) { // Module not found + ctxCancelFn() return nil, nil } } diff --git a/server/runtime_test.go b/server/runtime_test.go index 128b81e7d2b2ab3be60175899f1b28ec67c80efa..5b32a646bb1f6c9024ac476bec08e4b1bcc4b363 100644 --- a/server/runtime_test.go +++ b/server/runtime_test.go @@ -354,7 +354,7 @@ nakama.register_rpc(test.printWorld, "helloworld")`, } db := NewDB(t) - pipeline := NewPipeline(logger, cfg, db, jsonpbMarshaler, jsonpbUnmarshaler, nil, nil, nil, nil, nil, runtime) + pipeline := NewPipeline(logger, cfg, db, jsonpbMarshaler, jsonpbUnmarshaler, nil, nil, nil, nil, nil, nil, runtime) apiServer := StartApiServer(logger, logger, db, jsonpbMarshaler, jsonpbUnmarshaler, cfg, nil, nil, nil, nil, nil, nil, nil, nil, metrics, pipeline, runtime) defer apiServer.Stop()