posit-dev / posit-dev/py-shiny

Errors in server function are printed as `_send_error_response` messages

Open
#261 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.8k
Forks
135
Avg merge
2d 18h
Merged PRs (30d)
21

Description

When an error occurs in the server function, it gets printed to the console in a weird way. Here's an example app:

from shiny import App, render, ui

app_ui = ui.page_fluid("hello")

def server(input, output, session):
    raise ValueError()

app = App(app_ui, server)
INFO:     127.0.0.1:51018 - "GET / HTTP/1.1" 200 OK
INFO:     127.0.0.1:51018 - "GET /shiny-autoreload.js HTTP/1.1" 200 OK
INFO:     ('127.0.0.1', 51021) - "WebSocket /websocket/" [accepted]
INFO:     connection open
_send_error_response: this is an error

Also in shinylive:

image (17)

A bisect traced it to #250:

*   1255ce1 Merge pull request #250 from rstudio/cpuinfo-example (7 days ago) <Winston Chang>
|\  
| * 73caa99 (refs/bisect/bad) Fix wasm (7 days ago) <Joe Cheng>
| * 799ed22 (refs/bisect/skip-799ed22d1ebf35eb6e5e51343c794ab031f8a89a) Fix connection issues (8 days ago) <Joe Cheng>
| * 66a55c5 (HEAD, refs/bisect/good-66a55c5e502fa16f883a152f97f57e1518a57fc3) Add example (9 days ago) <Joe Cheng>
* | 32edac6 Add reactive.poll to API reference (7 days ago) <Carson>
|/  
* 84df91e (refs/bisect/good-84df91ea8aab49b0d0775c73110c15bd40f38cca) Fix types (9 days ago) <Winston Chang>

Note that the previous behavior wasn't entirely correct either. The error only printed in the JS console (and not the Python console), and the app would not gray-out.
image

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal Python app in the issue and reproduce the server-function error. Compare the behavior before and after the changes in #250, especially the bisected “Fix wasm” commit. Done means errors are reported appropriately without the _send_error_response message, and the app's error state behaves correctly in both the Python console and shinylive.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.