# Debug runtime code

**URL:** <https://forum.heroiclabs.com/t/debug-runtime-code/1059>\
**Category:** Local Setup\
**Tags:** server-framework\
**Created:** [October 19, 2020, 6:03am UTC](https://forum.heroiclabs.com/t/debug-runtime-code/1059 "2020-10-19T06:03:52Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![laimonas](https://avatars.discourse-cdn.com/v4/letter/l/eada6e/32.png) [@laimonas](https://forum.heroiclabs.com/u/laimonas)\
**Post date:** [October 19, 2020, 6:03am UTC](https://forum.heroiclabs.com/t/debug-runtime-code/1059/1 "2020-10-19T06:03:52Z")

</div>

Hi is there a way to debug runtime code? By debugging I mean attaching a debugger and adding breakpoints/inspecting execution. Yesterday I had a hard time figuring out issues with my runtime code which I could have easily solved in debugger mode

---

<div class="post-metadata">

**Author:** ![novabyte](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/novabyte/32/1324_2.png) [@novabyte](https://forum.heroiclabs.com/u/novabyte)\
**Post date:** [October 20, 2020, 6:59am UTC](https://forum.heroiclabs.com/t/debug-runtime-code/1059/2 "2020-10-20T06:59:20Z")

</div>

Hi @laimonas welcome 👋

Which language do you use with the server runtime? There’s a way to attach the [Delve debugger](https://github.com/go-delve/delve) to your Go code but at the moment there’s no way to attach the debugger to the Lua virtual machine inside the game server.

---

<div class="post-metadata">

**Author:** ![laimonas](https://avatars.discourse-cdn.com/v4/letter/l/eada6e/32.png) [@laimonas](https://forum.heroiclabs.com/u/laimonas)\
**Post date:** [October 20, 2020, 7:55am UTC](https://forum.heroiclabs.com/t/debug-runtime-code/1059/3 "2020-10-20T07:55:11Z")

</div>

Hey thank you for the reply 🙂 So far I’ve been writing runtime code in Lua but if theere’s no debugging option for it I’ll probably switch to Go. Are there known technical limitations as to why Lua debugging is not supported and are there plans to support Lua debugging in the future?

---

<div class="post-metadata">

**Author:** ![novabyte](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/novabyte/32/1324_2.png) [@novabyte](https://forum.heroiclabs.com/u/novabyte)\
**Post date:** [October 20, 2020, 9:48am UTC](https://forum.heroiclabs.com/t/debug-runtime-code/1059/4 "2020-10-20T09:48:37Z")

</div>

@laimonas The main challenge with debugger support for Lua in Nakama is that the virtual machine implementation is in pure Go. We’d need to implement the symbol analysis and debug data capture to support live stack and heap inspection.

Perhaps we’ll tackle it in the future but right now we’re focused on JavaScript support as another scripting language which developers can use to write server logic in. You can see progress on it on GitHub.

---

<div class="post-metadata">

**Author:** ![laimonas](https://avatars.discourse-cdn.com/v4/letter/l/eada6e/32.png) [@laimonas](https://forum.heroiclabs.com/u/laimonas)\
**Post date:** [October 20, 2020, 10:13am UTC](https://forum.heroiclabs.com/t/debug-runtime-code/1059/5 "2020-10-20T10:13:11Z")

</div>

Thanks for clarifying 🙂

---

<div class="post-metadata">

**Author:** ![formatCvt](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/formatcvt/32/1127_2.png) [@formatCvt](https://forum.heroiclabs.com/u/formatCvt)\
**Post date:** [February 16, 2022, 7:49am UTC](https://forum.heroiclabs.com/t/debug-runtime-code/1059/6 "2022-02-16T07:49:32Z")

</div>

Hi! What about debug javascript server logic?

---

<div class="post-metadata">

**Author:** ![flavio](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/flavio/32/2161_2.png) [@flavio](https://forum.heroiclabs.com/u/flavio)\
**Post date:** [February 16, 2022, 10:33am UTC](https://forum.heroiclabs.com/t/debug-runtime-code/1059/7 "2022-02-16T10:33:46Z")

</div>

Hello @formatCvt. Currently, we have support for javascript but not to the extend required to use debuggers. The debugging limitations presented by @novabyte apply to this runtime too.

To allow you to test the code, maybe you could use a test-oriented approach by leveraging mocking libraries, such as `ts-jest` or `ts-auto-mock` . It would allow you to stub the runtime calls and assert over their args.

---

<div class="post-metadata">

**Author:** ![harunhadi](https://avatars.discourse-cdn.com/v4/letter/h/ec9cab/32.png) [@harunhadi](https://forum.heroiclabs.com/u/harunhadi)\
**Post date:** [February 17, 2022, 11:40am UTC](https://forum.heroiclabs.com/t/debug-runtime-code/1059/8 "2022-02-17T11:40:20Z")

</div>

Could you send me the docker & docker compose files because I couldn’t manage to work with delve.

---

<div class="post-metadata">

**Author:** ![Faircyan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/faircyan/32/1085_2.png) [@Faircyan](https://forum.heroiclabs.com/u/Faircyan)\
**Post date:** [April 5, 2022, 11:08am UTC](https://forum.heroiclabs.com/t/debug-runtime-code/1059/9 "2022-04-05T11:08:33Z")

</div>

Hello. Is there a way to use debugger in WebStorm or any IDE now?. It doesn’t matter with or without docker. (JavaScript)

---

<div class="post-metadata">

**Author:** ![ftkg](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/ftkg/32/1180_2.png) [@ftkg](https://forum.heroiclabs.com/u/ftkg)\
**Post date:** [April 5, 2022, 12:04pm UTC](https://forum.heroiclabs.com/t/debug-runtime-code/1059/10 "2022-04-05T12:04:31Z")

</div>

Hello @Faircyan , there’s still no support for debuggers on the javascript runtime. See @flavio’s post above.

---

<div class="post-metadata">

**Author:** ![formatCvt](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/formatcvt/32/1127_2.png) [@formatCvt](https://forum.heroiclabs.com/u/formatCvt)\
**Post date:** [April 9, 2022, 2:57pm UTC](https://forum.heroiclabs.com/t/debug-runtime-code/1059/11 "2022-04-09T14:57:15Z")

</div>

yep, goja (the JS engine Nakama uses) have no debugger support, but they working on it [Goja debugger · Issue #294 · dop251/goja · GitHub](https://github.com/dop251/goja/issues/294)

---

<div class="post-metadata">

**Author:** ![mengxin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/mengxin/32/1879_2.png) [@mengxin](https://forum.heroiclabs.com/u/mengxin)\
**Post date:** [April 8, 2024, 8:52am UTC](https://forum.heroiclabs.com/t/debug-runtime-code/1059/12 "2024-04-08T08:52:08Z")

</div>

> [@laimonas](#):
>
> Hi is there a way to debug runtime code? By debugging I mean attaching a debugger and adding breakpoints/inspecting execution. Yesterday I had a hard time figuring out issues with my runtime code which I could have easily solved in debugger mode
> 
> > [@](#):
> >
> > Hi @laimonas welcome 👋 Which language do you use with the server runtime? There’s a way to attach the [Delve debugger](https://github.com/go-delve/delve) to your Go code but at the moment there’s no way to attach the debugger to the Lua virtual machine inside the game server.

Even the current jest, although already good for test code, is still looking forward to the JS debugging support.
