fix(dev): Linux tauri:dev startup failures (WebKitGTK load + i18n mount race)#498
Open
Raymond8196 wants to merge 2 commits into
Open
fix(dev): Linux tauri:dev startup failures (WebKitGTK load + i18n mount race)#498Raymond8196 wants to merge 2 commits into
Raymond8196 wants to merge 2 commits into
Conversation
Raymond8196
marked this pull request as draft
July 23, 2026 12:02
Since e06f4b4 ("isolate dual-instance cloud collaboration"), App is loaded via a runtime dynamic `import("@src/App")`, which webpack emits as a separate chunk. WebKitGTK (Linux dev) cannot load that chunk: under eval-cheap-module-source-map the App chunk inlines every module's source and balloons to ~77MB, and the WebView fails the dynamic import at runtime → "Initialization Failed" that blocks the whole app. Even after moving the source map out of the chunk (37MB standalone), WebKitGTK still fails the *runtime dynamic* import — the trigger is the loading mechanism, not only the size. Two coordinated dev-only changes; production is untouched: - src/index.tsx: in dev, mark the App import with `/* webpackMode: "eager" */`. App is no longer emitted as a separate runtime chunk — it is bundled into main.js — while `import()` keeps its Promise-returning semantics, so the runtime-identity setup still runs before the App module tree evaluates. Production keeps the normal dynamic import (prod minifies and ships no eval source maps, so the App chunk stays small there). - webpack.config.js: dev `devtool` switches from `eval-cheap-module-source-map` to `cheap-source-map`. Since App now lives inside main.js, eval mode would inline every module's source into main.js (~80MB, still un-loadable). cheap-source-map writes the map to a separate lazily-loaded .map file instead, keeping the executable main.js at ~41MB. Line-level debuggability is unchanged. Cost: incremental dev rebuilds are marginally slower (a .map file is written each time). Verified on Linux: `pnpm tauri:dev` reaches the main UI instead of the "Initialization Failed" emergency screen. main.js is ~41MB and App is no longer a 404'd/oversized runtime chunk.
On slow cold starts the parallel init Promise.all lost the 10s Promise.race against INIT_TIMEOUT_MS; the rejection was swallowed and React mounted before i18n.init() completed. The first useTranslation() then hit i18next's not-yet-initialized this.store → "undefined is not an object (evaluating 'this.store.hasLanguageSomeTranslations')". i18n is not degradable — App renders useTranslation() unconditionally — so pull i18nReady out of the bounded race and await it unconditionally after the degradable ops settle. It still starts at module load and runs parallel to the other ops, so the await only blocks when locale bundles are genuinely still loading. A rejection now surfaces the emergency error UI instead of mounting a guaranteed-to-crash React tree.
Raymond8196
force-pushed
the
fix/dev-init-webkit-chunk
branch
from
July 24, 2026 03:29
92ef89b to
1aa39a3
Compare
Raymond8196
marked this pull request as ready for review
July 24, 2026 03:35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #508 — on Linux,
pnpm tauri:devfails to reach the main UI due to tworelated dev-only startup failures.
Two coordinated, dev-only commits; production builds are untouched.
Commit 1 —
fix(dev): keep App bundled into main.js so WebKitGTK can load itSince
e06f4b471, App is loaded via a runtime dynamicimport("@src/App"),which webpack emits as a separate chunk. Under
eval-cheap-module-source-mapthat chunk inlines every module's source and balloons to ~77MB; WebKitGTK
fails the runtime dynamic import → "Initialization Failed".
src/index.tsx: in dev, mark the App import with/* webpackMode: "eager" */. App is bundled intomain.jsinstead ofbeing a separate runtime chunk, while
import()keeps its Promise-returningsemantics (so App module-tree eval still runs after the runtime-identity
config). Production keeps the normal dynamic import.
webpack.config.js: devdevtoolswitches fromeval-cheap-module-source-maptocheap-source-map(separate lazily-loaded.mapfile), keeping the executablemain.jsat ~41MB with line-leveldebuggability. Cost: incremental dev rebuilds are marginally slower.
Commit 2 —
fix(dev): await i18n before React mount to avoid store-undefined crashOn a slow cold start the parallel init
Promise.allloses the 10sPromise.race; the rejection was swallowed and React mounted beforei18n.init()completed, crashing the firstuseTranslation()call oni18next's not-yet-initialized
this.store.i18n is not degradable (App calls
useTranslation()unconditionally atrender), so pull
i18nReadyout of the bounded race andawaititunconditionally after the degradable ops settle. It still starts at module
load and runs parallel to the other ops, so the await only blocks when
locale bundles are genuinely still loading. On rejection, surface the
emergency error UI instead of mounting a guaranteed-to-crash React tree.
Production safety
webpackMode: "eager"is gated behindisDev(compile-time). Productionkeeps the normal dynamic import.
devtoolchange is dev-only:useDevSourceMaps = !isProduction && ...,so production
devtoolstaysfalse.awaitchange is runtime code but correct regardless of build:i18n must be initialized before React renders
useTranslation()consumers.Test plan
pnpm tauri:devon Linux reaches the main UI (no "Initialization Failed")hasLanguageSomeTranslations;no manual reload needed
eslint src/index.tsx— cleantsc --noEmit— no new errors (3 pre-existing errors insrc/modules/ProjectManager/are unrelated to this change)pnpm tauri:devon macOS is unaffectedpnpm tauri:build) is unaffectedVerified on Ubuntu 22.04 / WebKitGTK. Regression range: since
e06f4b471.