Confluence Cloud Connect JS cannot get context JWT on `dialog.submit` event handler

Hey, I’m running into an issue setting the event handler for the ‘dialog.submit’ event in a macro editor.

I want to use context tokens to make API calls as part of the process of editing the macro, however, when I try to get a context token in the ‘dialog.submit’ event handler, it fails.
The real problem is the execution just interrupts, no exception nor other errors are thrown.

The following is the code snippet. It is worth mentioning that the same code snippet works if I set it on another event listener e.g. a the click on a button of my form.

private setSaveMacroListener(): void {'dialog.submit', async () => {
            const token = await new Promise((resolve) => AP.context.getToken((token) => resolve(token)));
            return true;