mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-17 17:09:40 +02:00
Applied formatting to 1487+ files using pnpm format:write - TypeScript/JavaScript files - Svelte components - Astro pages - JSON configs - Markdown docs 13 files still need manual review (Astro JSX comments)
115 lines
2.5 KiB
Markdown
115 lines
2.5 KiB
Markdown
# 🐛 process-jobs Function - Bug Fix Plan
|
|
|
|
## Problem
|
|
|
|
Die `process-jobs` Edge Function wirft einen Runtime Error:
|
|
|
|
```
|
|
{"success":false,"error":"Cannot read properties of undefined (reading 'substring')"}
|
|
```
|
|
|
|
## Root Cause Analysis
|
|
|
|
Der Fehler tritt auf, bevor unser Code überhaupt läuft. Mögliche Ursachen:
|
|
|
|
1. **Import Problem:** `import { processGeneration } from '../process-generation/index.ts';`
|
|
- Dieser relative Import könnte bei Deno/Edge Functions Probleme verursachen
|
|
- Das File wird zwar hochgeladen, aber vielleicht nicht korrekt aufgelöst
|
|
|
|
2. **Supabase Client:** Der createClient() Call schlägt fehl wenn SUPABASE_URL leer ist
|
|
- Der Error `reading 'substring'` deutet auf URL-Parsing hin
|
|
|
|
## Solution Options
|
|
|
|
### Option A: Inline process-generation Code (EMPFOHLEN)
|
|
|
|
**Pros:**
|
|
|
|
- Keine Import-Probleme
|
|
- Alle Funktionalität in einer Datei
|
|
- Einfacher zu debuggen
|
|
|
|
**Cons:**
|
|
|
|
- Code-Duplizierung
|
|
- Größere Datei (~1000 Zeilen)
|
|
|
|
### Option B: Fix Import Path
|
|
|
|
**Pros:**
|
|
|
|
- Saubere Code-Organisation
|
|
- Wiederverwendbarkeit
|
|
|
|
**Cons:**
|
|
|
|
- Schwierig zu debuggen
|
|
- Deno Import-Semantik kann tricky sein
|
|
|
|
### Option C: Separate Functions (No Imports)
|
|
|
|
**Pros:**
|
|
|
|
- Klare Trennung
|
|
- Einfachere Edge Function
|
|
|
|
**Cons:**
|
|
|
|
- Mehr HTTP Overhead
|
|
- Komplexere Orchestrierung
|
|
|
|
## Recommended Fix: Option A (Inline)
|
|
|
|
Da wir `processGeneration` nur in `process-jobs` verwenden, macht es Sinn, den Code zu inlinen.
|
|
|
|
### Steps:
|
|
|
|
1. **Kopiere process-generation Code** in process-jobs
|
|
2. **Entferne den Import**
|
|
3. **Deploy und teste**
|
|
|
|
### Alternative Quick Fix
|
|
|
|
Falls das nicht funktioniert, können wir auch:
|
|
|
|
1. Nur download-image Jobs verarbeiten
|
|
2. generate-image Jobs über eine HTTP POST an process-generation delegieren
|
|
|
|
## Testing Plan
|
|
|
|
1. **Minimal Test:**
|
|
|
|
```bash
|
|
curl -X POST \
|
|
https://mjuvnnjxwfwlmxjsgkqu.supabase.co/functions/v1/process-jobs \
|
|
-H 'Authorization: Bearer SERVICE_ROLE_KEY'
|
|
```
|
|
|
|
Should return: `{"success": true, "processed": 0, "errors": 0}`
|
|
|
|
2. **With Job Test:**
|
|
|
|
```sql
|
|
-- Create test job
|
|
SELECT enqueue_job(
|
|
'generate-image',
|
|
'{"generation_id": "test", "prompt": "test", "model_id": "flux-schnell"}'::jsonb,
|
|
0
|
|
);
|
|
```
|
|
|
|
Then trigger process-jobs and check if job is claimed.
|
|
|
|
3. **Full E2E Test:**
|
|
Use start-generation with authenticated user and watch the full flow.
|
|
|
|
## Implementation
|
|
|
|
Ich würde vorschlagen:
|
|
|
|
1. Erstelle eine `process-jobs-v2.ts` mit inline Code
|
|
2. Deploye als neue Function
|
|
3. Teste
|
|
4. Wenn erfolgreich, ersetze die alte
|
|
|
|
Will ich das jetzt implementieren?
|