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] When Use fetch in js to send message to my python process, #2046

Open
shikoumuzi opened this issue Nov 13, 2024 · 2 comments
Open

[bug] When Use fetch in js to send message to my python process, #2046

shikoumuzi opened this issue Nov 13, 2024 · 2 comments
Labels
bug Something isn't working plugin: http

Comments

@shikoumuzi
Copy link

shikoumuzi commented Nov 13, 2024

Describe the bug

When I want to use tauri's fetch function to send data to my python program ( this program start in tauri::Command), I send it smoothly and get response in the first time, and when I send data to the same url the second time, the fetch function gets stuck in the "req.arrayBuffer()" step and keeps asking for memory. Until the webview crashes.
This only happens in release mode, not in dev mode
image

Reproduction

No response

Expected behavior

This only happens in release mode, not in dev mode。
I just call the function above:

function sendMsgToPythonSocket(path: String, message: Map<String, Object>): Promise<any> {
    console.log(path, message)
    return new Promise( (resolve, reject) => {
        console.log("http promise init")
        RustFetch("http://localhost:10025/py_tool_manager" + path, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json', 
            },
            body: JSON.stringify(message),
        }).then(
            (response: Response) => {
                response.clone().text()
                    .then(data => {
                        console.log(data)
                        resolve({
                            "data": data
                        });
                    })
            }
        )
        // console.log(await response.text())
    } )

}

default.json

{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "default",
  "description": "Capability for the main window",
  "remote": {
    "urls": ["https://", "http://" ],
    "http":{
      "urls": [
        "http://localhost:10025/*",
        "http://localhost:10025/tools_init"
      ]
    },
    "websocket": {
      "urls": [
        "ws://localhost:10025",
        "ws://localhost:10025/*"
      ]
    }
  },
  "windows": [
    "main"
  ],
  "permissions": [
    "core:default",
    "shell:allow-open",
    "core:window:allow-start-dragging",
    "core:window:allow-close",
    "core:window:allow-maximize",
    "core:window:allow-minimize",
    "core:window:allow-start-resize-dragging",
    "dialog:default",
    {
      "identifier": "shell:allow-execute",
      "allow": [
        {
          "name": "exec-sh",
          "cmd": "sh",
          "args": [
            "-c",
            {
              "validator": "\\S+"
            }
          ],
          "sidecar": false
        },
        {
          "name": "exec-cmd",
          "cmd": "cmd",
          "args": [
            "/c",
            {
              "validator": "\\S+"
            }
          ],
          "sidecar": false
        }
      ]
    },
    "process:default",
    "websocket:default",
    "websocket:allow-connect",
    "websocket:allow-send",
    {
      "identifier": "http:default",
      "allow": [{ "url": "https://*.tauri.app" }, { "url": "http://localhost:10025/**" }]
    },
    "http:allow-fetch",
    "http:allow-fetch-send",
    "http:allow-fetch-read-body",
    "http:allow-fetch-cancel"
  ]
}

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.19045 x86_64 (X64)
    ✔ WebView2: 130.0.2849.80
    ✔ MSVC: Visual Studio Community 2022
    ✔ rustc: 1.80.1 (3f5fd8dd4 2024-08-06)
    ✔ cargo: 1.80.1 (376290515 2024-07-16)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (environment override by RUSTUP_TOOLCHAIN)
    - node: 20.16.0
    - pnpm: 9.12.1
    - npm: 10.8.1

[-] Packages
    - tauri 🦀: 2.0.4
    - tauri-build 🦀: 2.0.1
    - wry 🦀: 0.46.1
    - tao 🦀: 0.30.3
    - tauri-cli 🦀: 2.0.3
    - @tauri-apps/api : 2.0.2 (outdated, latest: 2.1.1)
    - @tauri-apps/cli : 2.0.3 (outdated, latest: 2.1.0)

[-] Plugins
    - tauri-plugin-fs 🦀: 2.0.3
    - @tauri-apps/plugin-fs : not installed!
    - tauri-plugin-dialog 🦀: 2.0.3
    - @tauri-apps/plugin-dialog : 2.0.1
    - tauri-plugin-http 🦀: 2.0.3
    - @tauri-apps/plugin-http : 2.0.1
    - tauri-plugin-process 🦀: 2.0.1
    - @tauri-apps/plugin-process : 2.0.0
    - tauri-plugin-shell 🦀: 2.0.1
    - @tauri-apps/plugin-shell : 2.0.0 (outdated, latest: 2.0.1)
    - tauri-plugin-localhost 🦀: 2.0.1
    - @tauri-apps/plugin-localhost : not installed!
    - tauri-plugin-websocket 🦀: 2.0.1
    - @tauri-apps/plugin-websocket : 2.0.0

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: Vue.js
    - bundler: Vite

Stack trace

No response

Additional context

No response

@FabianLars FabianLars transferred this issue from tauri-apps/tauri Nov 13, 2024
@FabianLars FabianLars added bug Something isn't working plugin: http labels Nov 13, 2024
@amrbashir
Copy link
Member

amrbashir commented Nov 14, 2024

Please provide a minimal repro as I wasn't able to reproduce

@shikoumuzi
Copy link
Author

shikoumuzi commented Nov 18, 2024

Please provide a minimal repro as I wasn't able to reproduce

I try to use origin fetch, axios and reqwest (provide a invoke interfece for js to call) to replace tauri http and I found it happen in every function which is return promise when it call in el-dialog for element-plus, Later I will try to provide a minimal repro to you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working plugin: http
Projects
None yet
Development

No branches or pull requests

3 participants