Commit 80b2204
committed
fix: Gemma4 worker must be classic type — module worker breaks CDN dynamic import
Root cause: initAiWorker creates workers with {type:'module'} but ai-worker-gemma4.js
uses dynamic import() of external CDN URL (jsdelivr transformers.js). In Vite dev
mode, module workers have their imports intercepted by the bundler which cannot
resolve https://cdn.jsdelivr.net/... URLs, causing immediate worker.onerror and
the 'Worker failed to initialize' message in the consent modal.
Fix:
- ai-assistant.js: read cfg.workerType; default 'module' for existing workers
- ai-models.js: workerType:'classic' on gemma4-e2b and gemma4-e4b
- ai-worker-gemma4.js: unhandledrejection safety net, try/catch in message
handler, null-check for Gemma4ForConditionalGeneration/Gemma4Processor1 parent a5440fc commit 80b2204
3 files changed
Lines changed: 12 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
697 | 697 | | |
698 | 698 | | |
699 | 699 | | |
700 | | - | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
701 | 705 | | |
702 | 706 | | |
703 | 707 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
| |||
124 | 125 | | |
125 | 126 | | |
126 | 127 | | |
| 128 | + | |
127 | 129 | | |
128 | 130 | | |
129 | 131 | | |
| |||
0 commit comments