My WebAssembly module is unable to be properly loaded in node10, and manual destruction is not logged by `Room.getEventLog()`

  • Shard effected:

    mainly shard3, but all shards are affected in theory

    Things went wrong:

    My compiled WebAssembly code can only be loaded randomly by randomly changing code. (Source code is in: and other C files in the natives/libs directory.)

    I compiled the C code in my submitting script by using command (Can be found in

    Note that I'm using emscripten v3.1.24 and Python v3.10.8

    emcc -s WASM=1 -s SIDE_MODULE=1 -O3 "files" -o "output.wasm"

    What I have done:

    1. the type of distance_map in parameters of generate_distance_map was u_int8_t. I performed an invalid comparison with value -1. The module was successfully loaded.
    2. I changed the -1 to 0xff, then the module was unable to be loaded.
    3. I have changed the type of distance_map to int, and changed 0xff to -1, it still could not be loaded.
    4. I have changed the first assignment of node_to_visit. This line was changed from int node_to_visit[2500] = {0}; to int * node_to_visit = malloc(sizeof(int) * 2500);. The module was successfully loaded but reports there is no anything like malloc or memcpy.
    5. I copied a malloc implementation and memcpy implemention from github and glibc, pasting them into one file called flowfield.c. It was successfully loaded and was ready to run.
    6. I moved the library code into separate files and made some header files. the WebAssembly was unable to load.

    All error occurred in things I've done above is just WebAssembly.Module(): Wasm decoding failed: mutable globals cannot be imported @+119.

    And I've tested in newer nodejs after v12 LTS, it can be loaded normally and nothing went wrong. So I guess it's the problem of nodejs and Screeps are running on nodejs 10 which I'm unable to put my code on. So I wonder is there any plan to upgrade nodejs? Maybe most player don't need to upgrade it but I do need.

    It might be something wrong deep in nodejs and WebAssembly internals. I don't have enough knowledge about it and tried to download the source code but failed to build an analysis environment. If someone know why this happens I would appreciate to know about.

    The second one is that the object destruction like creep's death and structure destruction, the latter can only be logged when it is triggered by a creep attack or dismantle. I've already opened this issue in github ( but I didn't receive any response. I need event log to save my CPU ;w;