Skip to content

Commit da237f0

Browse files
committed
debug: Add detailed logging to investigate Tauri parameter passing issue
- Add debug logging to write_file Rust command to see received parameters - Add debug logging to JavaScript execute function to see sent parameters - Fix test to pass all required parameters (including null for optional) - This will help identify if the issue is in parameter serialization/deserialization
1 parent 23a1462 commit da237f0

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

e2e/test/tauri/api.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ describe('Tauri API', () => {
3333
const testContent = 'Hello, Tauri!';
3434

3535
console.log('🔍 Testing write_file command with path:', testPath);
36-
const result = await browser.tauri.execute('write_file', testPath, testContent);
36+
const result = await browser.tauri.execute('write_file', testPath, testContent, null);
3737
console.log('🔍 write_file result:', JSON.stringify(result, null, 2));
3838
expect(result.success).to.be.true;
3939

4040
// Verify with read
4141
console.log('🔍 Testing read_file command with path:', testPath);
42-
const readResult = await browser.tauri.execute('read_file', testPath);
42+
const readResult = await browser.tauri.execute('read_file', testPath, null);
4343
console.log('🔍 read_file result:', JSON.stringify(readResult, null, 2));
4444
expect(readResult.success).to.be.true;
4545
expect(readResult.data).to.equal(testContent);

fixtures/tauri-apps/basic/src-tauri/src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ async fn read_file(path: String, _options: Option<FileOperationOptions>) -> Resu
127127

128128
#[tauri::command]
129129
async fn write_file(path: String, contents: String, _options: Option<FileOperationOptions>) -> Result<(), String> {
130-
let log_msg = format!("🔍 Rust: write_file called with path: '{}', contents length: {}\n", path, contents.len());
130+
let log_msg = format!("🔍 Rust: write_file called with path: '{}', contents length: {}, options: {:?}\n", path, contents.len(), _options);
131131
let _ = std::fs::write("/tmp/tauri-debug.log", log_msg.as_bytes());
132-
println!("🔍 Rust: write_file called with path: '{}', contents length: {}", path, contents.len());
132+
println!("🔍 Rust: write_file called with path: '{}', contents length: {}, options: {:?}", path, contents.len(), _options);
133133

134134
std::fs::write(&path, contents).map_err(|e| {
135135
let error_msg = format!("Failed to write file '{}': {}", path, e);
@@ -170,6 +170,7 @@ async fn get_current_dir() -> Result<String, String> {
170170
.map_err(|e| e.to_string())
171171
}
172172

173+
173174
#[tauri::command]
174175
async fn get_platform_info() -> Result<PlatformInfo, String> {
175176
let mut sys = System::new_all();

packages/tauri-service/src/commands/execute.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ export async function executeTauriCommand<T = unknown>(
1818
const result = await browser.execute(
1919
(cmd: string, ...cmdArgs: unknown[]) => {
2020
console.log('🔍 Executing Tauri command:', cmd, 'with args:', cmdArgs);
21+
console.log(
22+
'🔍 Args types:',
23+
cmdArgs.map((arg) => typeof arg),
24+
);
25+
console.log(
26+
'🔍 Args JSON:',
27+
cmdArgs.map((arg) => JSON.stringify(arg)),
28+
);
2129

2230
// Tauri v2 uses window.__TAURI__.core.invoke
2331
// @ts-expect-error - Tauri command API injected at runtime

0 commit comments

Comments
 (0)