tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[bug] Build fails if front-end files are collectively too large.

Open Braxtogoo opened this issue 11 months ago • 2 comments

Describe the bug

I have been running into an issue where my tauri app will not build if my front-end assets amount to around 1 GB or more of data. If I delete enough assets the project builds. The project I have been testing with is the basic "Getting Started" project using JavaScript, npm, and Vanilla presets. The only thing I've changed is the front-end. Below is a rough tree of my project and it's file sizes.

src | |index.html(82 KB) |[14 other html files](979 KB) | |_assets | |_fonts(308 KB) |_gallery(148 MB) |_images(27 MB) |_libraries(928 KB) |_app(337 MB) |_obj(684 MB) |_videos(298 MB)

If I delete both the app and video folders, the project builds. Alternatively I can leave those folders and delete the obj folder which will also allow me to build.

If I attempt to build without removing assets I receive errors stating that random metafiles are corrupt. Depending on what I delete the metafile that corrupts changes but stays consistent.

I am attempting to use Tauri in place of a current Electron solution, and due to limitations of this project all assets must be bundled with the project.

Reproduction

My guess would be to reproduce this you need to make a tauri app based of the quick start project and fill it's front-end with more than a gigabyte of assets.

Expected behavior

Expected a build of my app to be packaged.

Full tauri info output

[✔] Environment

    - OS: Windows 10.0.19045 x86_64 (X64)

    ✔ WebView2: 131.0.2903.112

    ✔ MSVC: Visual Studio Professional 2022

    ✔ rustc: 1.84.0 (9fc6b4312 2025-01-07)

    ✔ cargo: 1.84.0 (66221abde 2024-11-19)

    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)

    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)

    - node: 20.18.0

    - npm: 10.8.2

 

[-] Packages

    - tauri 🦀: 2.2.2

    - tauri-build 🦀: 2.0.5

    - wry 🦀: 0.48.1

    - tao 🦀: 0.31.1

    - @tauri-apps/api : not installed!

    - @tauri-apps/cli : 2.2.4

 

[-] Plugins

    - tauri-plugin-opener 🦀: 2.2.4

    - @tauri-apps/plugin-opener : not installed!

 

[-] App

    - build-type: bundle

    - CSP: unset

    - frontendDist: ../src

Stack trace

PS C:\{USER_DIR}\Documents\TauriTests\Test1\test-app> npm run tauri build

 

> [email protected] tauri

> tauri build

   Compiling test-app v0.1.0 (C:\{USER_DIR}\Documents\TauriTests\Test1\test-app\src-tauri)

error[E0786]: found invalid metadata files for crate `test_app_lib`

--> src\main.rs:5:5

  |

5 |     test_app_lib::run()

  |     ^^^^^^^^^^^^

  |

  = note: corrupt metadata encountered in \\?\C:\ {USER_DIR}\Documents\TauriTests\Test1\test-app\src-tauri\targ

 

For more information about this error, try `rustc --explain E0786`.

error: could not compile `test-app` (bin "test-app") due to 1 previous error

failed to build app: failed to build app

    Error failed to build app: failed to build app

Additional context

Some experiments I've tried is creating a base getting started app and only adding my asset files, this also caused the build to fail.

Braxtogoo avatar Jan 14 '25 22:01 Braxtogoo

I've encountered the same problem, bundling a big amount of map tiles files (~900MB) resulting build failure, has any solution? error: linking with link.exe failed: exit code: 1120

ygnid avatar Dec 10 '25 09:12 ygnid

I can't think of a solution right now, i feel like this is just a limitation of our approach to inline assets into the binary. The tauri-way of bundling large files would be to use the resources feature and then load these files via the asset protocol via https://v2.tauri.app/reference/javascript/api/namespacecore/#convertfilesrc

FabianLars avatar Dec 10 '25 09:12 FabianLars