fix: SQLite boolean binding + React StrictMode race condition
- Fix: SqliteAdapter.createLayer/updateLayer: convert JS booleans to integers (true→1, false→0)
- Root cause: better-sqlite3 cannot bind JS booleans, causing layer creation to fail
- Without layers, no elements could be created, making the entire CAD editor non-functional
- Fix: loadProjectDataTyped: remove Superseded throw for React StrictMode double-render safety
- Root cause: StrictMode double-render created two load requests, first was superseded and
set savedStatus to 'Fehler beim Laden', overwriting the successful second request
- Fix: App.tsx catch block: ignore cancelled/superseded errors to prevent false error status
- All tests pass: Backend 239/239, Frontend 374/374
- UI Test verified: Login → Dashboard → Project → CAD Editor → Line drawing → 4 elements created
This commit is contained in:
@@ -354,6 +354,9 @@ const CADEditor: React.FC<CADEditorProps> = ({ projectId, token, onNavigateBack
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
// Ignore race condition errors from React StrictMode double-render
|
||||
if (cancelled) return;
|
||||
if (err instanceof Error && err.message.includes('Superseded')) return;
|
||||
console.error('Failed to load project:', err);
|
||||
setSavedStatus('Fehler beim Laden');
|
||||
}
|
||||
|
||||
@@ -478,13 +478,7 @@ export async function loadProjectDataTyped(token: string, projectId: string): Pr
|
||||
getBlocks(token, drawing.id),
|
||||
]);
|
||||
|
||||
// Only use the result if this is still the latest request for this project
|
||||
const latestRequestId = projectLoadRequestCounter.get(projectId);
|
||||
if (latestRequestId !== currentRequestId) {
|
||||
// A newer request superseded this one — reject to prevent stale data
|
||||
throw new Error('Superseded by a newer load request');
|
||||
}
|
||||
|
||||
// Return data even if a newer request exists (React StrictMode double-render safe)
|
||||
return {
|
||||
project,
|
||||
drawing,
|
||||
|
||||
Reference in New Issue
Block a user