🔧 Improve search worker initialization and logging for better error handling and debugging
This commit is contained in:
@@ -431,7 +431,10 @@ const initSearchWorker = () => {
|
||||
|
||||
const handleSearchWorkerMessage = event => {
|
||||
const { type, id, results, percent, error: workerError } = event.data;
|
||||
console.log('📨 Worker message received:', type, { percent, resultCount: results?.length });
|
||||
console.log('📨 Worker message received:', type, {
|
||||
percent,
|
||||
resultCount: results?.length
|
||||
});
|
||||
|
||||
if (type === 'progress') {
|
||||
operationProgress.value.percent = percent;
|
||||
@@ -660,8 +663,16 @@ const onSearchInput = debounce(async () => {
|
||||
// Initialize worker if needed
|
||||
initSearchWorker();
|
||||
|
||||
if (!searchWorker) {
|
||||
console.error('❌ Worker failed to initialize');
|
||||
operationProgress.value.active = false;
|
||||
operationProgress.value.message = 'Worker failed to initialize';
|
||||
return;
|
||||
}
|
||||
|
||||
// Show progress for long searches
|
||||
const searchTerm = searchQuery.value.toLowerCase();
|
||||
console.log('🔍 Starting worker search for:', searchTerm);
|
||||
operationProgress.value = {
|
||||
active: true,
|
||||
percent: 0,
|
||||
@@ -673,6 +684,12 @@ const onSearchInput = debounce(async () => {
|
||||
searchWorkerRequestId++;
|
||||
const requestId = searchWorkerRequestId;
|
||||
|
||||
console.log('📤 Posting message to worker:', {
|
||||
linesCount: fileLines.value.length,
|
||||
searchTerm,
|
||||
requestId
|
||||
});
|
||||
|
||||
searchWorker.postMessage({
|
||||
lines: fileLines.value,
|
||||
searchTerm: searchTerm,
|
||||
|
||||
Reference in New Issue
Block a user