fix: a few regressions from previous PRs#23
Conversation
| *self.window_id.lock().unwrap(), | ||
| self.webview_id, | ||
| WebviewMessage::DeleteCookie(cookie.clone().into_owned()), | ||
| WebviewMessage::SetCookie(cookie.into_owned()), |
There was a problem hiding this comment.
🔴 delete_cookie sends SetCookie message instead of DeleteCookie
The delete_cookie function incorrectly sends WebviewMessage::SetCookie instead of WebviewMessage::DeleteCookie, causing cookies to be set/updated rather than deleted.
Click to expand
Impact
When a user calls delete_cookie() to remove a cookie from the webview, the cookie will NOT be deleted. Instead, it will be set or updated with the provided cookie data. This is the opposite of the intended behavior.
Root Cause
The change at line 1718 replaced WebviewMessage::DeleteCookie(cookie.clone().into_owned()) with WebviewMessage::SetCookie(cookie.into_owned()).
Evidence
The DeleteCookie message variant exists and is properly handled:
crates/tauri-runtime-wry/src/lib.rs:1410:DeleteCookie(tauri_runtime::Cookie<'static>),crates/tauri-runtime-wry/src/lib.rs:3737-3740: Handler that callswebview.delete_cookie(&cookie)
But the dispatch function sends the wrong message:
fn delete_cookie(&self, cookie: Cookie<'_>) -> Result<()> {
send_user_message(
&self.context,
Message::Webview(
*self.window_id.lock().unwrap(),
self.webview_id,
WebviewMessage::SetCookie(cookie.into_owned()), // BUG: Should be DeleteCookie
),
)?;
Ok(())
}Recommendation: Change WebviewMessage::SetCookie(cookie.into_owned()) to WebviewMessage::DeleteCookie(cookie.into_owned()) to correctly dispatch the delete cookie message.
Was this helpful? React with 👍 or 👎 to provide feedback.
Benchmark PR from qodo-benchmark#170