mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-12 12:40:29 +08:00
Cache an error from app.submit() and show it on frontend (#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>
This commit is contained in:
parent
0efd72e608
commit
595ebf74c5
6
.changeset/rich-bikes-crash.md
Normal file
6
.changeset/rich-bikes-crash.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
"@gradio/app": patch
|
||||
"gradio": patch
|
||||
---
|
||||
|
||||
feat:Cache an error from app.submit() and show it on frontend
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user