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

[bug] Always get Uncaught (in promise) invalid utf-8 sequence of 1 bytes from index 2 with sidecar #5912

Closed
Hellager opened this issue Dec 26, 2022 · 5 comments
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@Hellager
Copy link

Describe the bug

I'm trying to use the sidecar feature, so i write a console app with c# to test.
The app works well when give it correct options and will return error message if options are wrong.
But when i try using the sidecar feature to call it, the result will always be
Uncaught (in promise) invalid utf-8 sequence of 1 bytes from index 2, even if specific the output format to UTF8.
Try put them all under the src-tauri folder won't fix it.
I'm not sure whats wrong, any idea?

Reproduction

  1. Here's my test project tauri-sidecar-test
  2. The MyConsoleApp folder is a visual studio console app project and build it will get the MyConsoleApp.exe which is the test program for Tauri sidecar.
  3. Run the test project and click the Greet button, you will see the Uncaught (in promise) invalid utf-8 sequence of 1 bytes from index 2

Expected behavior

No response

Platform and versions

Environment
› OS: Windows 10.0.22000 X64
› Webview2: 108.0.1462.54
› MSVC:
- Visual Studio Community 2022
› Node.js: 16.15.1
› npm: 8.15.0
› pnpm: 7.13.4
› yarn: 1.22.19
› rustup: 1.24.3
› rustc: 1.62.0
› cargo: 1.62.0
› Rust toolchain: stable-x86_64-pc-windows-msvc

Packages
› @tauri-apps/cli [NPM]: 1.2.2
› @tauri-apps/api [NPM]: 1.2.0
› tauri [RUST]: 1.2.2,
› tauri-build [RUST]: 1.2.1,
› tao [RUST]: 0.15.8,
› wry [RUST]: 0.23.4,

App
› build-type: bundle
› CSP: unset
› distDir: ../dist
› devPath: http://localhost:1420/
› framework: React
› bundler: Vite

App directory structure
├─ .git
├─ .vscode
├─ MyConsoleApp
├─ node_modules
├─ public
├─ src
└─ src-tauri

Stack trace

No response

Additional context

No response

@Hellager Hellager added status: needs triage This issue needs to triage, applied to new issues type: bug labels Dec 26, 2022
@amrbashir
Copy link
Member

Please provide the sidecar binary so I can test this without having to setup c# dev env.

@Hellager
Copy link
Author

The sidecar binary is in src-tauri/console, run it with option -l will have the expected result.
The c# project is to prove that the console app itself is clean and works well, you don't need to setup a c# env.

@Hellager Hellager reopened this Dec 28, 2022
@amrbashir
Copy link
Member

amrbashir commented Dec 28, 2022

Works fine here, the app fails to launch (different issue) but no errors.

image

Seems like this is the same issue as #5309 which I can't reproduce. Can you try providing a utf-8 encoding like this:

const command = Command.sidecar("console/MyConsoleApp", ["-l"], { encoding: 'utf-8' })

@Hellager
Copy link
Author

Thanks for your help.
Now with { encoding: 'utf-8' }, the stderr result turns to be

δ���������쳣:  System.TypeInitializationException: ��QuickAccessShell.Program�������ͳ�ʼֵ�趨�������쳣�� ---> System.IO.FileNotFoundException: δ�ܼ����ļ�����򼯡�NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c��������ijһ�������ϵͳ�Ҳ���ָ�����ļ���
   �� QuickAccessShell.Program..cctor()
   --- �ڲ��쳣��ջ���ٵĽ�β ---
   �� QuickAccessShell.Program.Main(String[] args)

I've updated my console app. With any execution, it will have a log message saved in file.
And i find that there's no log file in src-tauri\target\debug, which means the console app is not even executed.

According to the error message in stderr, i'm doubting that the console app is not able to find it's corresponding dll.
So i put them all directly under the src-tauri folder and update my tauri.conf.json, but get the same result.

The console app itself is good to run directly in the src-tauri\target\debug

@amrbashir
Copy link
Member

amrbashir commented Jan 2, 2023

According to the error message in stderr, i'm doubting that the console app is not able to find it's corresponding dll.

Same as #5844 which is being fixed in #5950

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

2 participants