heroiclabs / nakama

Distributed server for social and realtime games and apps.
https://heroiclabs.com
Apache License 2.0
8.58k stars 1.06k forks source link

ast.Property is *ast.PropertyShort, not *ast.PropertyKeye #1202

Closed CristianoDigitalmoka closed 1 month ago

CristianoDigitalmoka commented 2 months ago

I am having an issue when I update the nakama image from 3.17.1 to an updated version (checked with every version).

When I compose with Docker the Nakama Container goes down after a few seconds reporting this error:

2024-04-15 08:42:05 panic: interface conversion: ast.Property is ast.PropertyShort, not ast.PropertyKeyed [recovered] 2024-04-15 08:42:05 panic: interface conversion: ast.Property is ast.PropertyShort, not ast.PropertyKeyed [recovered] 2024-04-15 08:42:05 panic: interface conversion: ast.Property is ast.PropertyShort, not ast.PropertyKeyed [recovered] 2024-04-15 08:42:05 panic: interface conversion: ast.Property is ast.PropertyShort, not ast.PropertyKeyed 2024-04-15 08:42:05 2024-04-15 08:42:05 goroutine 1 [running]: 2024-04-15 08:42:05 github.com/dop251/goja.(Runtime).runWrapped.func1() 2024-04-15 08:42:05 github.com/dop251/goja@v0.0.0-20240220182346-e401ed450204/runtime.go:2442 +0x171 2024-04-15 08:42:05 panic({0x1e11bc0?, 0xc0007669c0?}) 2024-04-15 08:42:05 runtime/panic.go:914 +0x21f 2024-04-15 08:42:05 github.com/dop251/goja.(vm).handleThrow(0xc000116fc0, {0x1e11bc0, 0xc0007669c0}) 2024-04-15 08:42:05 github.com/dop251/goja@v0.0.0-20240220182346-e401ed450204/vm.go:788 +0x425 2024-04-15 08:42:05 github.com/dop251/goja.(vm).try.func1() 2024-04-15 08:42:05 github.com/dop251/goja@v0.0.0-20240220182346-e401ed450204/vm.go:807 +0x3f 2024-04-15 08:42:05 panic({0x1e11bc0?, 0xc0007669c0?}) 2024-04-15 08:42:05 {"level":"info","ts":"2024-04-15T06:42:05.606Z","caller":"migrate/migrate.go:226","msg":"Successfully applied migration","count":0} 2024-04-15 08:42:05 {"level":"info","ts":"2024-04-15T06:42:05.617Z","caller":"server/config.go:90","msg":"Successfully loaded config file","path":"/nakama/data/local.yml"} 2024-04-15 08:42:05 runtime/panic.go:914 +0x21f 2024-04-15 08:42:05 github.com/dop251/goja.(vm).handleThrow(0xc000116fc0, {0x1e11bc0, 0xc0007669c0}) 2024-04-15 08:42:05 github.com/dop251/goja@v0.0.0-20240220182346-e401ed450204/vm.go:788 +0x425 2024-04-15 08:42:05 github.com/dop251/goja.(vm).runTryInner.func1() 2024-04-15 08:42:05 github.com/dop251/goja@v0.0.0-20240220182346-e401ed450204/vm.go:830 +0x3f 2024-04-15 08:42:05 panic({0x1e11bc0?, 0xc0007669c0?}) 2024-04-15 08:42:05 runtime/panic.go:914 +0x21f 2024-04-15 08:42:05 github.com/heroiclabs/nakama/v3/server.(RuntimeJavascriptInitModule).getMatchHookFnIdentifier(0xc000288fc0, 0xc0005bf3e8?, 0x7fe900742ce8?, {0xc0000e8d5b, 0xb}, {0xc00054009a, 0x2}, {0x200b370, 0x9}) 2024-04-15 08:42:05 github.com/heroiclabs/nakama/v3/server/runtime_javascript_init.go:1619 +0x7c9 2024-04-15 08:42:05 github.com/heroiclabs/nakama/v3/server.(RuntimeJavascriptInitModule).extractMatchFnKey(0x27d2268?, 0xc000766930?, {0xc00054009a, 0x2}, {0x200b370, 0x9}) 2024-04-15 08:42:05 github.com/heroiclabs/nakama/v3/server/runtime_javascript_init.go:1570 +0x8a 2024-04-15 08:42:05 github.com/heroiclabs/nakama/v3/server.(RuntimeJavascriptInitModule).mappings.(RuntimeJavascriptInitModule).registerMatch.func12({{0x27d2268, 0xc0007319b0}, {0xc0000011c0, 0x2, 0x4}}) 2024-04-15 08:42:05 github.com/heroiclabs/nakama/v3/server/runtime_javascript_init.go:1456 +0x198 2024-04-15 08:42:05 github.com/dop251/goja.(nativeFuncObject).vmCall(0xc00047a820, 0xc000116fc0, 0x2) 2024-04-15 08:42:05 github.com/dop251/goja@v0.0.0-20240220182346-e401ed450204/func.go:563 +0x186 2024-04-15 08:42:05 github.com/dop251/goja.call.exec(0xb?, 0xc000116fc0) 2024-04-15 08:42:05 github.com/dop251/goja@v0.0.0-20240220182346-e401ed450204/vm.go:3375 +0x66 2024-04-15 08:42:05 github.com/dop251/goja.(vm).run(0xc000116fc0) 2024-04-15 08:42:05 github.com/dop251/goja@v0.0.0-20240220182346-e401ed450204/vm.go:582 +0x5b 2024-04-15 08:42:05 github.com/dop251/goja.(vm).runTryInner(0xc000116fc0?) 2024-04-15 08:42:05 github.com/dop251/goja@v0.0.0-20240220182346-e401ed450204/vm.go:834 +0x65 2024-04-15 08:42:05 github.com/dop251/goja.(baseJsFuncObject).__call(0xc000000a80, {0xc000129bc0?, 0x4, 0xc0005bf800?}, {0x0?, 0x0}, {0x27d2a38?, 0x34b7600?}) 2024-04-15 08:42:05 github.com/dop251/goja@v0.0.0-20240220182346-e401ed450204/func.go:426 +0x70f 2024-04-15 08:42:05 github.com/dop251/goja.(baseJsFuncObject)._call(...) 2024-04-15 08:42:05 github.com/dop251/goja@v0.0.0-20240220182346-e401ed450204/func.go:442 2024-04-15 08:42:05 github.com/dop251/goja.(baseJsFuncObject).call(0x27d2268?, {{0x27d2a38, 0x34b7600}, {0xc000129bc0, 0x4, 0x4}}, {0x0?, 0x0?}) 2024-04-15 08:42:05 github.com/dop251/goja@v0.0.0-20240220182346-e401ed450204/func.go:450 +0x76 2024-04-15 08:42:05 github.com/dop251/goja.(baseJsFuncObject).Call(...) 2024-04-15 08:42:05 github.com/dop251/goja@v0.0.0-20240220182346-e401ed450204/func.go:382 2024-04-15 08:42:05 github.com/dop251/goja.AssertFunction.func1.1() 2024-04-15 08:42:05 github.com/dop251/goja@v0.0.0-20240220182346-e401ed450204/runtime.go:2402 +0x71 2024-04-15 08:42:05 github.com/dop251/goja.(vm).try(0xc000116fc0, 0xc0005bf9d8) 2024-04-15 08:42:05 github.com/dop251/goja@v0.0.0-20240220182346-e401ed450204/vm.go:811 +0x25b 2024-04-15 08:42:05 github.com/dop251/goja.(Runtime).runWrapped(0xc000481c00, 0x7fe900f58508?) 2024-04-15 08:42:05 github.com/dop251/goja@v0.0.0-20240220182346-e401ed450204/runtime.go:2446 +0x71 2024-04-15 08:42:05 github.com/dop251/goja.AssertFunction.func1({0x27d2a38?, 0x34b7600?}, {0xc000129bc0?, 0x27a3ec0?, 0x6?}) 2024-04-15 08:42:05 github.com/dop251/goja@v0.0.0-20240220182346-e401ed450204/runtime.go:2401 +0x8c 2024-04-15 08:42:05 github.com/heroiclabs/nakama/v3/server.evalRuntimeModules(0xc000140500, 0xc000544200, 0xc000456e40, 0xc0000a0960, {0x27bf668, 0xc00022cf20}, {0x27c1748?, 0xc000043900}, 0x27d09b0?, 0xc000453580, ...) 2024-04-15 08:42:05 github.com/heroiclabs/nakama/v3/server/runtimejavascript.go:2399 +0x795 2024-04-15 08:42:05 github.com/heroiclabs/nakama/v3/server.NewRuntimeProviderJS({, }, , , , , , {, }, {0x27a3ec0, ...}, ...) 2024-04-15 08:42:05 github.com/heroiclabs/nakama/v3/server/runtimejavascript.go:705 +0x11db 2024-04-15 08:42:05 github.com/heroiclabs/nakama/v3/server.NewRuntime({0x27be058, }, , , , , , {, _}, {0x27a3ec0, ...}, ...) 2024-04-15 08:42:05 github.com/heroiclabs/nakama/v3/server/runtime.go:657 +0xf5e 2024-04-15 08:42:05 main.main() 2024-04-15 08:42:05 main.go:164 +0x1a5e

These are the relevant files for the Typescript project

{ "files": [ "./src/main.ts", "./src/match_handler.ts", "./src/testFunctions.ts", "./src/interfaces.ts", "./src/enums.ts", "./src/consts.ts" ], "compilerOptions": { "target": "es2016", / Set the JavaScript language version for emitted JavaScript and include compatible library declarations. / "esModuleInterop": true, / Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. / "forceConsistentCasingInFileNames": true, / Ensure that casing is correct in imports. / "strict": true, / Enable all strict type-checking options. / "skipLibCheck": true, / Skip type checking all .d.ts files. / "outFile": "./build/index.js", "typeRoots": [ "./node_modules" ] } }

version: '3' services: cockroachdb: image: cockroachdb/cockroach:latest-v23.1 command: start-single-node --insecure --store=attrs=ssd,path=/var/lib/cockroach/ restart: "no" volumes:

const rpcIdHealthCheck = 'HealthCheck';

function InitModule(ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, initializer: nkruntime.Initializer) {

initializer.registerRpc(rpcIdHealthCheck, rpcHealthcheck);

initializer.registerMatch('match', {
    matchInit,
    matchJoinAttempt,
    matchJoin,
    matchLeave,
    matchLoop,
    matchTerminate,
    matchSignal
});

}

const matchInit : nkruntime.MatchInitFunction = function (ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, params: {[key: string]: string}): {state: nkruntime.MatchState, tickRate: number, label: string} { logger.debug('Lobby match created');

return {
    state: { Debug: true },
    tickRate: 10,
    label: 'wow'
};

};

const matchJoin : nkruntime.MatchJoinFunction = function (ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, dispatcher: nkruntime.MatchDispatcher, tick: number, state: nkruntime.MatchState, presences: nkruntime.Presence[]) : { state: nkruntime.MatchState } | null { presences.forEach(function (presence) { state.presences[presence.userId] = presence; logger.debug('%q joined Lobby match', presence.userId); });

return {
    state
};

}

const matchJoinAttempt : nkruntime.MatchJoinAttemptFunction = function (ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, dispatcher: nkruntime.MatchDispatcher, tick: number, state: nkruntime.MatchState, presence: nkruntime.Presence, metadata: {[key: string]: any }) : {state: nkruntime.MatchState, accept: boolean, rejectMessage?: string | undefined } | null { logger.debug('%q attempted to join Lobby match', ctx.userId);

return {
    state,
    accept: true
};

}

const matchLeave : nkruntime.MatchLeaveFunction = function (ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, dispatcher: nkruntime.MatchDispatcher, tick: number, state: nkruntime.MatchState, presences: nkruntime.Presence[]) : { state: nkruntime.MatchState } | null { presences.forEach(function (presence) { state.presences[presence.userId] = presence; logger.debug('%q left Lobby match', presence.userId); });

return {
    state
};

}

const matchLoop : nkruntime.MatchLoopFunction = function (ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, dispatcher: nkruntime.MatchDispatcher, tick: number, state: nkruntime.MatchState, messages: nkruntime.MatchMessage[]) : { state: nkruntime.MatchState} | null { logger.debug('Lobby match loop executed');

return {
    state
};

}

const matchSignal : nkruntime.MatchSignalFunction = function (ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, dispatcher: nkruntime.MatchDispatcher, tick: number, state: nkruntime.MatchState, data: string) : { state: nkruntime.MatchState, data?: string } | null { logger.debug('Lobby match signal received: ' + data);

return {
    state,
    data: "Lobby match signal received: " + data
};

}

const matchTerminate : nkruntime.MatchTerminateFunction = function (ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, dispatcher: nkruntime.MatchDispatcher, tick: number, state: nkruntime.MatchState, graceSeconds: number) : { state: nkruntime.MatchState} | null { logger.debug('Lobby match terminated');

return {
    state
};

}

If i Remove the the match registration in the InitModule function i do not have the error anymore

linear[bot] commented 2 months ago

NK-541 ast.Property is *ast.PropertyShort, not *ast.PropertyKeye

sesposito commented 1 month ago

@CristianoDigitalmoka can you please provide the transpiled index.js file that is produced by the above?

sesposito commented 1 month ago

We'll close this issue, please re-open it if you can provide a bundled index.js file to reproduce it on the latest Nakama version.