# InitModule (TypeScript) executed twice when start nakama 3.0

**URL:** <https://forum.heroiclabs.com/t/initmodule-typescript-executed-twice-when-start-nakama-3-0/1304>\
**Category:** Game Design\
**Created:** [January 20, 2021, 3:35am UTC](https://forum.heroiclabs.com/t/initmodule-typescript-executed-twice-when-start-nakama-3-0/1304 "2021-01-20T03:35:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Okno](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/okno/32/1470_2.png) [@Okno](https://forum.heroiclabs.com/u/Okno)\
**Post date:** [January 20, 2021, 3:35am UTC](https://forum.heroiclabs.com/t/initmodule-typescript-executed-twice-when-start-nakama-3-0/1304/1 "2021-01-20T03:35:24Z")

</div>

I’m running sample code from here [https://heroiclabs.com/docs/runtime-code-typescript-setup/](https://heroiclabs.com/docs/runtime-code-typescript-setup/) with a little modification

- delete “module”: “CommonJS” in tsconfig
- start nakama with: nakama --runtime.js\_entrypoint “…/…/build/index.js”

When nakama starts, the code in InitModule is executed twice.

My main.ts file:

```
let count = 0;
let InitModule: nkruntime.InitModule =
    function (ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, initializer: nkruntime.Initializer) {
        logger.info("Hello World! " + count++);
    }

```

Output:  
…  
{“level”:“info”,“ts”:“2021-01-20T10:33:14.010+0700”,“caller”:“server/runtime\_javascript.go:494”,“msg”:“Initialising JavaScript runtime provider”,“path”:"/Users/cuong/Documents/TDG/Cocos/nakama/data/modules",“entrypoint”:"…/…/build/index.js"}  
{“level”:“info”,“ts”:“2021-01-20T10:33:14.011+0700”,“caller”:“server/runtime\_javascript\_logger.go:68”,“msg”:“Hello World! 0”}  
{“level”:“info”,“ts”:“2021-01-20T10:33:14.011+0700”,“caller”:“server/runtime\_javascript\_logger.go:68”,“msg”:“Hello World! 1”}  
{“level”:“info”,“ts”:“2021-01-20T10:33:14.011+0700”,“caller”:“server/runtime\_javascript.go:1419”,“msg”:“JavaScript runtime modules loaded”}  
…

So, is this a bug?

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [January 21, 2021, 12:54pm UTC](https://forum.heroiclabs.com/t/initmodule-typescript-executed-twice-when-start-nakama-3-0/1304/2 "2021-01-21T12:54:38Z")

</div>

Hey @Okno, after inspection I can confirm this to be a bug, I’ve opened the following issue: [JS Runtime invokes InitModule function twice · Issue #530 · heroiclabs/nakama · GitHub](https://github.com/heroiclabs/nakama/issues/530).

We’ll work on a fix and a new release soon to address it, thanks for your post.
