Skip to content

:start sometimes gets called twice (ClojureScript) #112

@jwr

Description

@jwr

After a grueling multi-day trial-and-error debugging session I have finally confirmed that it is possible for the :start method to be called twice by mount in ClojureScript.

I suspected this for a long time, I even had an atom to guard and log cases of dual invocation in one of my files, but I always wrote it off as a temporary browser caching phenomenon, as I only noticed it in development, not in production bundle. However, recently it started happening in the production bundle as well.

Unfortunately, I can't provide a reproducible case. This seems to be an extremely elusive bug: it seems to depend on file sizes or file arrangement. Once the app is built, it will happen predictably every time, and recompiling the same code will reproduce the problem as well, but adding even a single println might stop it from happening. Then removing the println makes it happen again.

In my case, it happens in with a namespace that is used by lots of other namespaces. Race condition somewhere, perhaps?

I verified that mount/start is called only once.

I realize this isn't much to go on, but I think it's something worth knowing. Perhaps others can deduce how this is possible, perhaps safeguards can be put in place so that it doesn't happen. It can result in really hard-to-track problems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions