Promise returned from typesetPromise never resolves?

30 views
Skip to first unread message

Krasi Mir

unread,
Mar 25, 2026, 12:08:00 PM (7 days ago) Mar 25
to MathJax Users
Hello,

What could be the reason that the promise returned from typesetPromise does not resolve in MathJax 4.1.0? In 3.1.4 it was working fine. We just upgraded some apps to 4.1.0 and started experiencing this.

Thanks,
Krasimir

Davide Cervone

unread,
Mar 25, 2026, 3:56:22 PM (7 days ago) Mar 25
to mathja...@googlegroups.com
It is hard to tell what might be happening for you without more details about the calls you are making, and your workflow.

One change in v4 from v3 is that in v3, you needed to be careful about not making multiple calls to the promise-based functions at the same time, and the documentation encouraged you to use MathJax.startup.promise to serialize the calls.  In v4, there is a new internal promise that is used for that purpose and the promise calls use it automatically.  that means you no longer need to use Mathjax.startup.promise yourself, and indeed if you are, that may be the source of the problem for you.

See the documentation in the What's New in v4 section, in particular,


for more details.

If that is not what is happening for you, then we will need more information about your setup in order to help diagnose the problem.  A minimal (non-)working example would help.

Davide


--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mathjax-users/8f41a70e-8de6-442b-a7a3-9481fd293dd6n%40googlegroups.com.

Krasi Mir

unread,
Mar 26, 2026, 6:39:23 AM (6 days ago) Mar 26
to MathJax Users
Hi Davide,

Thanks for answering and apologies for not providing much information yesterday. It was a bit of a stressful situation as the issue started happening on production and the initial investigation fell on me. Then several managers started asking questions, more teams were involved, meetings, craziness. I had time to only come in here and ask this quick question as soon as I discovered that typesetPromise's promise was not resolving.

What I am seeing is that if the content to typeset contains no math, the promise resolves. If there is math, it does not resolve. I have tried it on just one math and as simple as 'x'. It is important to say that the math seems to be typeset correctly and there are no errors. It's just the promise that hangs. I'll continue digging and post here as soon as I have something.

Krasimir

Krasi Mir

unread,
Mar 26, 2026, 6:41:42 AM (6 days ago) Mar 26
to MathJax Users
P.S. We did use MathJax.startup.promise in v3 but I saw the note about it not being needed in v4 and removed it. That didn't fix the issue.

Davide Cervone

unread,
Mar 26, 2026, 7:14:57 AM (6 days ago) Mar 26
to mathja...@googlegroups.com
OK, thanks for the additional information.  If you can provide a minimal example, I can look into it, but without that, there isn't much I can do.  Many people are using v4 without issue, so it must have something to do with your setup.  I am mot able to reproduce the problem without knowing what that is.

Can you share your MathJax configuration and something about how you are making the calls?

Davide



Krasi Mir

unread,
Mar 26, 2026, 7:22:34 AM (6 days ago) Mar 26
to MathJax Users
I understand that and am preparing a minimalistic HTML page to see if I will be able to reproduce the issue with it.

Davide Cervone

unread,
Mar 26, 2026, 7:24:53 AM (6 days ago) Mar 26
to mathja...@googlegroups.com

Davide Cervone

unread,
Mar 26, 2026, 7:41:07 AM (6 days ago) Mar 26
to mathja...@googlegroups.com
Are you using a startup.ready() or startup.pageReady() function in your configuration?  And if so, do you call MathJax.typesetPromise() from within one of those?  That might be the source of the problem.  Check out


for some details about how these should be used, and on a legitimate use of MathJax.startup.promise in startup.ready() functions.

I hope that helps.

Davide


On Mar 26, 2026, at 6:41 AM, Krasi Mir <krasyo....@gmail.com> wrote:

Krasi Mir

unread,
Mar 26, 2026, 8:15:52 AM (6 days ago) Mar 26
to MathJax Users
I have stripped off many changes that were added for v4 to our configuration (mostly accessibility stuff).
Currently the config uses startup.ready() like so:

    startup: {
        ready() {
            MathJax.startup.defaultReady();
        }
    }

So, it is very minimalistic and no, it does not call typesetPromise.
With this config, I am also experiencing the issue in our system.

I just finished testing a very simple HTML page: a button that when clicked adds math to a div and then calls typesetPromise on the div and displays a "Math generated" message when the promise resolves. It is working fine with the same config and MathJax as those used by our system. So the problem must be something specific to the pages in our system, maybe a script/tool or something is somehow interfering.

Davide, feel free to delete/close this thread as soon as you read this. If you are curious what's going on, keep it open and I'll post when we figure it out.
Thanks again!

Davide Cervone

unread,
Mar 26, 2026, 10:04:18 AM (6 days ago) Mar 26
to mathja...@googlegroups.com
OK, thanks for the update.  I'm wondering if your code could be calling MathJax.typesetPromise() before the startup.pageReady() function has run.  That might lead to a circular dependency (I haven't been able to get that to happen, though).

Can you try adding "typeset: false," to the "startup" block of your configuration and see if that still leads to typesetPromise() not returning?

Davide


Krasi Mir

unread,
Mar 26, 2026, 11:04:18 AM (6 days ago) Mar 26
to MathJax Users
I found the problem. We have a Content Security Policy in place and it is blocking a worker of MathJax:

worker_error.png
What are these workers? From this image alone, can you tell me what needs to be allowed in the policy? Or what other info do you want me to provide?

Krasi Mir

unread,
Mar 26, 2026, 11:31:41 AM (6 days ago) Mar 26
to MathJax Users
Adding "worker-src blob:" to the Content Security Policy solves the issue.

Davide, thanks for your help!

Davide Cervone

unread,
Mar 26, 2026, 12:25:52 PM (6 days ago) Mar 26
to mathja...@googlegroups.com
I'm glad you were able to find the problem and resolve it.

What are these workers? 

There is actually only one created.  It is used for the rather time-consuming process of generating the speech data for the expressions on the page.

It looks like it would be good for us to trap the error so that the speech-generation can be skipped rather than preventing the promise from resolving, or at least causing the promise to be rejected.  I will look into making that change.

Thanks for your report, and the resolution.

Davide


Reply all
Reply to author
Forward
0 new messages