Skip to content

Commit e98393e

Browse files
authored
fix: no longer unpacking and flattening payload, closes #7673 (#7677)
1 parent 41067ce commit e98393e

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

.changes/fix-ipc-payload.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": 'patch:bug'
3+
---
4+
5+
No longer unpacking and flattening the `payload` over the IPC so that commands with arguments called `cmd`, `callback`, `error`, `options` or `payload` aren't breaking the IPC.

core/tauri/scripts/core.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@
5959

6060
window.__TAURI_INVOKE__ = function invoke(cmd, payload = {}, options) {
6161
return new Promise(function (resolve, reject) {
62-
var callback = window.__TAURI__.transformCallback(function (r) {
62+
const callback = window.__TAURI__.transformCallback(function (r) {
6363
resolve(r)
6464
delete window[`_${error}`]
6565
}, true)
66-
var error = window.__TAURI__.transformCallback(function (e) {
66+
const error = window.__TAURI__.transformCallback(function (e) {
6767
reject(e)
6868
delete window[`_${callback}`]
6969
}, true)

core/tauri/scripts/ipc-protocol.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
})
4545
} else {
4646
// otherwise use the postMessage interface
47-
const { data } = processIpcMessage({ cmd, callback, error, options, ...payload })
47+
const { data } = processIpcMessage({ cmd, callback, error, options, payload })
4848
window.ipc.postMessage(data)
4949
}
5050
}

core/tauri/src/ipc/protocol.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ fn handle_ipc_message<R: Runtime>(message: String, manager: &WindowManager<R>, l
127127
cmd: String,
128128
callback: CallbackFn,
129129
error: CallbackFn,
130-
#[serde(flatten)]
131130
payload: serde_json::Value,
132131
options: Option<RequestOptions>,
133132
}
@@ -142,7 +141,6 @@ fn handle_ipc_message<R: Runtime>(message: String, manager: &WindowManager<R>, l
142141
cmd: String,
143142
callback: CallbackFn,
144143
error: CallbackFn,
145-
#[serde(flatten)]
146144
payload: crate::utils::pattern::isolation::RawIsolationPayload<'a>,
147145
options: Option<RequestOptions>,
148146
}

0 commit comments

Comments
 (0)