Skip to content

4.0.0 regression: Module.postRun callbacks not being calledΒ #23420

@sgbeal

Description

@sgbeal

While attempting to get SQLite building with Emscripten 4.0.0 we've discovered that our --extern-post-js code is failing because initialization which has formerly been done via Module.postRun is no longer being run (or is perhaps being run later than it historically did and we can't get to that point because our --extern-post-js requires the prior ordering).

This is most easily demonstrated with some console debug output comparing 3.1.74 (the last 3.1 release) and 4.0.0:

image

The relevant part is the 3rd yellow line on the left. That line, from the start of a Module.postRun handler, is never hit in 4.0.0.

i've not found any relevant change mentioned in recent change logs.

Adding this silly workaround to our extern-post-js code, from the then() handler of calling the EXPORT_NAME-defined module init function, works around the problem:

      if( EmscriptenModule.postRun && EmscriptenModule.postRun.length ){
        /* Emscripten 4.0.0 does not run postRun(). */
        console.warn("Emscripten did not run postRun: running them now!");
        EmscriptenModule.postRun.shift()(EmscriptenModule);
      }

Which makes it now behave like 3.1.74 except for the later timing of postRun():

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions