stlite icon indicating copy to clipboard operation
stlite copied to clipboard

@stlite/browser multipage apps crash with pyodide error on PC

Open nic-iqmo opened this issue 6 months ago • 5 comments

OS Version: Windows 11 Home, Version 24H2, Build 26100.4351. Chrome Version: 137.0.7151.69

Issue Description: After 10-20 minutes of running a multipage app, the entire app crashes with the error below. On PC this seems to happen on @stlite/browser >= 0.77.0. I've tested a number of different versions ranging from 76.0 to 83.0 and I'm seeing the bug on every version I've tested >= 0.77.0. I've also tested on both chrome and edge and the result is the same. On mac I can't reproduce the error.

Pyodide has suffered a fatal error. Please report this to the Pyodide maintainers.
   API.fatal_error                                      @ pyodide.asm.js:10
   callPyObjectKwargsPromising                          @ pyodide.asm.js:10
   await in callPyObjectKwargsPromising   
   Module.callPyObjectMaybePromising                    @ pyodide.asm.js:10
   wrapper                                              @ pyodide.asm.js:10
   e.port1.onmessage                                    @ pyodide.asm.js:10

The cause of the fatal error was:
   API.fatal_error                                      @ pyodide.asm.js:10
   callPyObjectKwargsPromising                          @ pyodide.asm.js:10
   await in callPyObjectKwargsPromising   
   Module.callPyObjectMaybePromising                    @ pyodide.asm.js:10
   wrapper                                              @ pyodide.asm.js:10
   e.port1.onmessage                                    @ pyodide.asm.js:10

RuntimeError: table index is out of bounds
      at cdn.jsdelivr.net/pyodide/v0.27.3/full/pyodide.asm.wasm
      at cdn.jsdelivr.net/pyodide/v0.27.3/full/pyodide.asm.wasm
      at cdn.jsdelivr.net/pyodide/v0.27.3/full/pyodide.asm.wasm
      at cdn.jsdelivr.net/pyodide/v0.27.3/full/pyodide.asm.wasm
      at cdn.jsdelivr.net/pyodide/v0.27.3/full/pyodide.asm.wasm
      at cdn.jsdelivr.net/pyodide/v0.27.3/full/pyodide.asm.wasm
      at cdn.jsdelivr.net/pyodide/v0.27.3/full/pyodide.asm.wasm
      at cdn.jsdelivr.net/pyodide/v0.27.3/full/pyodide.asm.wasm
      at cdn.jsdelivr.net/pyodide/v0.27.3/full/pyodide.asm.wasm
      at cdn.jsdelivr.net/pyodide/v0.27.3/full/pyodide.asm.wasm
   API.fatal_error                                      @ pyodide.asm.js:10
   callPyObjectKwargsPromising                          @ pyodide.asm.js:10
   await in callPyObjectKwargsPromising   
   Module.callPyObjectMaybePromising                    @ pyodide.asm.js:10
   wrapper                                              @ pyodide.asm.js:10
   e.port1.onmessage                                    @ pyodide.asm.js:10

Stack (most recent call first):
  File "/lib/python312.zip/pyodide/webloop.py", line 286 in call_soon                 pyodide.asm.js:10 
  File "/lib/python312.zip/asyncio/events.py", line 88 in _run                        pyodide.asm.js:10 
  File "/lib/python312.zip/pyodide/webloop.py", line 332 in run_handle                pyodide.asm.js:10 

I created an MRE to demonstrate. The MRE consists of a barebones flask server that serves a multipage Streamlit app where each app has a title and thats it.

Steps to Reproduce:

  1. cd into stlite_browser_broken_multipage_app_crashes
  2. Launch the flask server
  3. When the app had loaded, click on a page (e.g. page2)
  4. Let it sit until it fails

Link to MRE: https://github.com/NicholasGingrich/stliteTesting/tree/main/stlite_browser_broken_multipage_app_crashes

nic-iqmo avatar Jun 11 '25 20:06 nic-iqmo

Same issue on https://edit.share.stlite.net/ since 0.83

lukefullard avatar Jun 13 '25 01:06 lukefullard

Thank you both for the report! I will investigate the problem.

whitphx avatar Jun 13 '25 02:06 whitphx

Update: After turning off the JSPI (Java script promise integration) flag in Chrome, it seems that the bug no longer occurs.

To turn off the flag:

  1. Navigate to chrome://flags
  2. Find the flag entitled Experimental WebAssembly JavaScript Promise Integration (JSPI) and set the option to disabled

nic-iqmo avatar Jun 13 '25 13:06 nic-iqmo

Looks to be related to this: https://github.com/pyodide/pyodide/issues/5702

LukeAFullard avatar Jun 17 '25 09:06 LukeAFullard

This config works for me.

mount(
  {
    requirements: req,
    entrypoint: "app.py",
    files: files,
    streamlitConfig: {
      "server.fileWatcherType": "none",
    }
  },
  document.getElementById("root")
);

Since this error is triggered by a large number of Python async function calls, turning off the file watcher delays the crash significantly.

DarkGoldBar avatar Nov 13 '25 09:11 DarkGoldBar