Repository: gradio-app/gradio

Issue:
Custom js with multiple input and one output can not work as expect
### Describe the bug

When using custom js function, the gradio ui will wrap this function and make sure the payload is a list to adapt the backend routing rules.

https://github.com/gradio-app/gradio/blob/f36211050cf75b587027cf2a79e88b8c7a3a05fd/ui/packages/app/src/Blocks.svelte#L60-L74

I guess the original intention of this function is to check the `d.inputs.length`

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Reproduction

```python
import gradio


def inference(foo, bar):
    return foo + bar


with gradio.Blocks() as main:
    input1 = gradio.Textbox()
    input2 = gradio.Textbox()
    output = gradio.Text()
    btn = gradio.Button("submit")
    js = '(x, y) => { return [x, y]; }'
    btn.click(inference, inputs=[input1, input2], outputs=output, _js=js)

main.launch()
```

### Screenshot

_No response_

### Logs

```shell
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Traceback (most recent call last):
  File "/home/foo/.conda/envs/sw37/lib/python3.7/site-packages/gradio/routes.py", line 327, in run_predict
    iterators=iterators,
  File "/home/foo/.conda/envs/sw37/lib/python3.7/site-packages/gradio/blocks.py", line 1013, in process_api
    inputs = self.preprocess_data(fn_index, inputs, state)
  File "/home/foo/.conda/envs/sw37/lib/python3.7/site-packages/gradio/blocks.py", line 923, in preprocess_data
    processed_input.append(block.preprocess(inputs[i]))
IndexError: list index out of range
```


### System Info

```shell
gradio: 3.15.0
system: Arch Linux
browser: google-chrome 110.0.5481.177
```


### Severity

annoying


Discussion:

Resolving patch:
diff --git a/demo/blocks_js_methods/run.py b/demo/blocks_js_methods/run.py
--- a/demo/blocks_js_methods/run.py
+++ b/demo/blocks_js_methods/run.py
@@ -10,19 +10,32 @@
     with gr.Row():
         btn = gr.Button("Create sentence.")
         reverse_btn = gr.Button("Reverse sentence.")
-        foo_bar_btn = gr.Button("Foo bar.")
-    
+        foo_bar_btn = gr.Button("Append foo")
+        reverse_then_to_the_server_btn = gr.Button(
+            "Reverse sentence and send to server."
+        )
+
     def sentence_maker(w1, w2, w3):
         return f"{w1} {w2} {w3}"
 
     output1 = gr.Textbox(label="output 1")
     output2 = gr.Textbox(label="verb")
     output3 = gr.Textbox(label="verb reversed")
+    output4 = gr.Textbox(label="front end process and then send to backend")
 
     btn.click(sentence_maker, [subject, verb, object], output1)
-    reverse_btn.click(None, [subject, verb, object], output2, _js="(s, v, o) => o + ' ' + v + ' ' + s")
+    reverse_btn.click(
+        None, [subject, verb, object], output2, _js="(s, v, o) => o + ' ' + v + ' ' + s"
+    )
     verb.change(lambda x: x, verb, output3, _js="(x) => [...x].reverse().join('')")
     foo_bar_btn.click(None, [], subject, _js="(x) => x + ' foo'")
 
+    reverse_then_to_the_server_btn.click(
+        sentence_maker,
+        [subject, verb, object],
+        output4,
+        _js="(s, v, o) => [s, v, o].map(x => [...x].reverse().join(''))",
+    )
+
 if __name__ == "__main__":
-    demo.launch()
\ No newline at end of file
+    demo.launch()


Test patch: