Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: no longer unpacking and flattening payload, closes #7673 #7677

Merged
merged 3 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/fix-ipc-payload.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri": 'patch:bug'
---

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.
4 changes: 2 additions & 2 deletions core/tauri/scripts/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@

window.__TAURI_INVOKE__ = function invoke(cmd, payload = {}, options) {
return new Promise(function (resolve, reject) {
var callback = window.__TAURI__.transformCallback(function (r) {
const callback = window.__TAURI__.transformCallback(function (r) {
resolve(r)
delete window[`_${error}`]
}, true)
var error = window.__TAURI__.transformCallback(function (e) {
const error = window.__TAURI__.transformCallback(function (e) {
reject(e)
delete window[`_${callback}`]
}, true)
Expand Down
2 changes: 1 addition & 1 deletion core/tauri/scripts/ipc-protocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
})
} else {
// otherwise use the postMessage interface
const { data } = processIpcMessage({ cmd, callback, error, options, ...payload })
const { data } = processIpcMessage({ cmd, callback, error, options, payload })
window.ipc.postMessage(data)
}
}
Expand Down
2 changes: 0 additions & 2 deletions core/tauri/src/ipc/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ fn handle_ipc_message<R: Runtime>(message: String, manager: &WindowManager<R>, l
cmd: String,
callback: CallbackFn,
error: CallbackFn,
#[serde(flatten)]
payload: serde_json::Value,
options: Option<RequestOptions>,
}
Expand All @@ -142,7 +141,6 @@ fn handle_ipc_message<R: Runtime>(message: String, manager: &WindowManager<R>, l
cmd: String,
callback: CallbackFn,
error: CallbackFn,
#[serde(flatten)]
payload: crate::utils::pattern::isolation::RawIsolationPayload<'a>,
options: Option<RequestOptions>,
}
Expand Down
Loading