Skip to content

Commit

Permalink
Cache an error from app.submit() and show it on frontend (gradio-app#…
Browse files Browse the repository at this point in the history
…8115)

* Cache an error from app.submit() and show it on frontend

* Fix typing

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
whitphx and gradio-pr-bot authored Apr 25, 2024
1 parent 0efd72e commit 595ebf7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/rich-bikes-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/app": patch
"gradio": patch
---

feat:Cache an error from app.submit() and show it on frontend
23 changes: 20 additions & 3 deletions js/app/src/Blocks.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,30 @@
if (api_recorder_visible) {
api_calls = [...api_calls, payload];
}
const submission = app
.submit(
let submission: ReturnType<typeof app.submit>;
try {
submission = app.submit(
payload.fn_index,
payload.data as unknown[],
payload.event_data,
payload.trigger_id
)
);
} catch (e) {
const fn_index = 0; // Mock value for fn_index
messages = [new_message(String(e), fn_index, "error"), ...messages];
loading_status.update({
status: "error",
fn_index,
eta: 0,
queue: false,
queue_position: null
});
set_status($loading_status);
return;
}
submission
.on("data", ({ data, fn_index }) => {
if (dep.pending_request && dep.final_event) {
dep.pending_request = false;
Expand Down

0 comments on commit 595ebf7

Please sign in to comment.