matchCreate error

I have this code from docs:

function findOrCreateMatch(ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, payload: string): string {'findOrCreateMatch rpc called');
  const limit = 10;
  const isAuthoritative = true;
  const minSize = 1;
  const maxSize = 2;
  const label = "";
  var matches = nk.matchList(limit, isAuthoritative, label, minSize, maxSize, "");

  // If matches exist, sort by match size and return the largest.
  if (matches.length > 0) {
    matches.sort(function (a, b) {
      return a.size >= b.size ? 1 : -1;
    return matches[0].matchId;

  // If no matches exist, create a new one using the "lobby" module and return it's ID.
  var matchId = nk.matchCreate('supermatch', { debug: true });
  return JSON.stringify({ matchId });

however when I send request in API EXPLORER it gives me an error:
rpc error: code = Internal desc = GoError: error creating match: error creating match: not found at*runtimeJavascriptNakamaModule).matchCreate.func1 (native)

what am I doing wrong here?

Can you show us how you register/define “supermatch” ?

1 Like

been reading more about the docs, and found out that it might be the problem, I haven’t registered/defined it on my InitModule . Heres my main.ts that has the InitModule:

function InitModule(context: nkruntime.Context, logger: nkruntime.Logger, nakama: nkruntime.Nakama, initializer: nkruntime.Initializer) {
  initializer.registerRpc('matchmaker', findOrCreateMatch)'Javascript module loaded')

although I have tried this but it still doesn’t work:
nk.matchCreate('data/modules/build/index.js', { });

I’m confused on how do I register/define the module, can you point me to the right direction? really appreciate it.

@justin you have to register the match handlers as well (see this example:, and then you call matchCreate specifying the name you set upon registration.

I suggest you have a good look at the whole project I linked as it implements a tic-tac-toe backend in TS (and Go) for Nakama.



I see, so that’s what’s lacking in there. Thanks a bunch!