refactor(qr): improve QR scanner robustness and lifecycle management
- Add cleanup promise to prevent concurrent cleanup operations - Add proper component lifecycle tracking with isMounted flag - Add isCleaningUp flag to prevent operations during cleanup - Add debug level logging for better diagnostics - Add structured error logging with stack traces - Add proper error handling in component initialization - Add proper cleanup of event listeners and camera resources - Add proper handling of app pause/resume events - Add proper error boundaries around camera operations - Improve error message formatting and consistency The QR scanner now properly handles lifecycle events, cleans up resources, and provides better error diagnostics. This improves reliability on mobile devices and prevents potential memory leaks.
This commit is contained in:
@@ -20,6 +20,14 @@ function safeStringify(obj: unknown) {
|
||||
}
|
||||
|
||||
export const logger = {
|
||||
debug: (message: string, ...args: unknown[]) => {
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
// eslint-disable-next-line no-console
|
||||
console.debug(message, ...args);
|
||||
const argsString = args.length > 0 ? " - " + safeStringify(args) : "";
|
||||
logToDb(message + argsString);
|
||||
}
|
||||
},
|
||||
log: (message: string, ...args: unknown[]) => {
|
||||
if (
|
||||
process.env.NODE_ENV !== "production" ||
|
||||
|
||||
Reference in New Issue
Block a user