Skip to content

Shinylive apps are not isolated #75

@davidchall

Description

@davidchall

Transferred from quarto-dev/quarto-cli#13404

There is an issue with how auxiliary source files are located for Shinylive apps, so these apps are not truly isolated (as implied by the standalone config field). If I create 2 apps with conflicting auxiliary filenames, then 1 app will attempt to load the auxiliary file from the other app. It appears to be a race condition which app is located, because the working app alternates randomly.

Here's a MBE (also available at https://github.com/davidchall/quarto-shinylive-bug):

---
title: Test
format: html
filters:
  - shinylive
---

## App 1
```{shinylive-python}
#| standalone: true

## file: app.py
from helper import helper1
from shiny.express import input, render, ui

ui.input_numeric("numeric", "Numeric input", 1, min=1, max=10)

@render.text
def value():
    return input.numeric()

## file: helper.py
def helper1():
    return "This is a helper function"
```

## App 2
```{shinylive-python}
#| standalone: true

## file: app.py
from helper import helper2
from shiny.express import input, render, ui

ui.input_numeric("numeric", "Numeric input", 1, min=1, max=10)

@render.text
def value():
    return input.numeric()

## file: helper.py
def helper2():
    return "This is a different helper function"
```

But App 1 fails to load with error:

  File "/home/pyodide/app_0wpouot7xx0ufdvibcl1/app.py", line 1, in <module>
    from helper import helper1
ImportError: cannot import name 'helper1' from 'helper' (/home/pyodide/app_uwgf7rt7kak5fn8bus6x/helper.py). Did you mean: 'helper2'?

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