html export crashing at _emscripten_get_num_gamepads (Godot 2.1.6)

Godot Version

Godot 2.1.6

Question

I have written a game with Godot 2.1.6 2016. Now, I try to publish it as a website so I need to use the html exporter.

After I have loaded the export with python -m http.server to test it in my local web browsers, I get an black viewport and a never ending stream of the following error:

 exception thrown: TypeError: Cannot read properties of undefined (reading 'length'),TypeError: Cannot read properties of undefined (reading 'length')
    at _emscripten_get_num_gamepads (http://localhost:8000/index.js:1:153306)
    at Sg (http://localhost:8000/index.asm.js:19:22286)
    at Rg (http://localhost:8000/index.asm.js:19:22094)
    at ni (http://localhost:8000/index.asm.js:19:32854)
    at Pyj (http://localhost:8000/index.asm.js:26:82106)
    at http://localhost:8000/index.js:1:191040
    at Object.runIter (http://localhost:8000/index.js:1:134948)
    at http://localhost:8000/index.js:1:191021

Is there a fix or a workaround for this error?
Or do I need to post further information?

I have invented a workaround for this issue: Just edit index.js and replace the function _emscripten_get_num_gamepads(){return JSEvents.lastGamepadState.length} with an version always returning 0: _emscripten_get_num_gamepads(){return 0}.

On Linux, you can use the following command to do this automatically:

sed -i "s|_emscripten_get_num_gamepads(){return JSEvents.lastGamepadState.length}|_emscripten_get_num_gamepads(){return 0}|g" index.js

Sadly, this workaround will disable gamepad support.