Ignore scanner decode noise and log debug errors in dev
This commit is contained in:
@@ -843,6 +843,9 @@ export function labelCreatePageData(store) {
|
||||
|
||||
this.stopScanner();
|
||||
this.scannerState.isLoading = true;
|
||||
const shouldLogDecodeErrors = import.meta.env.DEV;
|
||||
let lastDecodeErrorName = '';
|
||||
let lastDecodeErrorAt = 0;
|
||||
|
||||
try {
|
||||
if (!this.scannerReader) {
|
||||
@@ -863,12 +866,19 @@ export function labelCreatePageData(store) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!error || error?.name === 'NotFoundException') {
|
||||
return;
|
||||
if (error) {
|
||||
// Continuous decode emits expected per-frame misses/errors before a valid barcode is found.
|
||||
// Keep the modal quiet and only surface startup failures from the outer catch block.
|
||||
if (shouldLogDecodeErrors) {
|
||||
const errorName = String(error?.name || 'UnknownError');
|
||||
const now = Date.now();
|
||||
if (errorName !== lastDecodeErrorName || now - lastDecodeErrorAt > 2000) {
|
||||
console.debug('[scanner] Ignoring frame decode error while scanning:', errorName, error?.message || '');
|
||||
lastDecodeErrorName = errorName;
|
||||
lastDecodeErrorAt = now;
|
||||
}
|
||||
|
||||
if (!this.scannerState.error) {
|
||||
this.scannerState.error = this.normalizeScannerError(error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@@ -509,6 +509,9 @@ export function stockDetailPageData(store) {
|
||||
|
||||
this.stopScanner();
|
||||
this.scannerState.isLoading = true;
|
||||
const shouldLogDecodeErrors = import.meta.env.DEV;
|
||||
let lastDecodeErrorName = '';
|
||||
let lastDecodeErrorAt = 0;
|
||||
|
||||
try {
|
||||
if (!this.scannerReader) {
|
||||
@@ -529,12 +532,19 @@ export function stockDetailPageData(store) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!error || error?.name === 'NotFoundException') {
|
||||
return;
|
||||
if (error) {
|
||||
// Continuous decode emits expected per-frame misses/errors before a valid barcode is found.
|
||||
// Keep the modal quiet and only surface startup failures from the outer catch block.
|
||||
if (shouldLogDecodeErrors) {
|
||||
const errorName = String(error?.name || 'UnknownError');
|
||||
const now = Date.now();
|
||||
if (errorName !== lastDecodeErrorName || now - lastDecodeErrorAt > 2000) {
|
||||
console.debug('[scanner] Ignoring frame decode error while scanning:', errorName, error?.message || '');
|
||||
lastDecodeErrorName = errorName;
|
||||
lastDecodeErrorAt = now;
|
||||
}
|
||||
|
||||
if (!this.scannerState.error) {
|
||||
this.scannerState.error = this.normalizeScannerError(error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user