Merge pull request #1688 from xKevIsDev/main

refactor: optimize error handling and npm install performance
This commit is contained in:
KevIsDev 2025-05-10 13:29:28 +01:00 committed by GitHub
commit b089a4b7f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 19 deletions

View File

@ -27,7 +27,8 @@ const IGNORE_PATTERNS = [
'**/npm-debug.log*', '**/npm-debug.log*',
'**/yarn-debug.log*', '**/yarn-debug.log*',
'**/yarn-error.log*', '**/yarn-error.log*',
'**/*lock.json',
// Include this so npm install runs much faster '**/*lock.json',
'**/*lock.yaml', '**/*lock.yaml',
]; ];

View File

@ -31,7 +31,8 @@ const IGNORE_PATTERNS = [
'**/npm-debug.log*', '**/npm-debug.log*',
'**/yarn-debug.log*', '**/yarn-debug.log*',
'**/yarn-error.log*', '**/yarn-error.log*',
'**/*lock.json',
// Include this so npm install runs much faster '**/*lock.json',
'**/*lock.yaml', '**/*lock.yaml',
]; ];

View File

@ -39,27 +39,13 @@ if (!import.meta.env.SSR) {
console.log('WebContainer preview message:', message); console.log('WebContainer preview message:', message);
// Handle both uncaught exceptions and unhandled promise rejections // Handle both uncaught exceptions and unhandled promise rejections
if ( if (message.type === 'PREVIEW_UNCAUGHT_EXCEPTION' || message.type === 'PREVIEW_UNHANDLED_REJECTION') {
message.type === 'PREVIEW_UNCAUGHT_EXCEPTION' ||
message.type === 'PREVIEW_UNHANDLED_REJECTION' ||
message.type === 'PREVIEW_CONSOLE_ERROR'
) {
const isPromise = message.type === 'PREVIEW_UNHANDLED_REJECTION'; const isPromise = message.type === 'PREVIEW_UNHANDLED_REJECTION';
const isConsoleError = message.type === 'PREVIEW_CONSOLE_ERROR'; const title = isPromise ? 'Unhandled Promise Rejection' : 'Uncaught Exception';
const title = isPromise
? 'Unhandled Promise Rejection'
: isConsoleError
? 'Console Error'
: 'Uncaught Exception';
workbenchStore.actionAlert.set({ workbenchStore.actionAlert.set({
type: 'preview', type: 'preview',
title, title,
description: description: 'message' in message ? message.message : 'Unknown error',
'message' in message
? message.message
: 'args' in message && Array.isArray(message.args) && message.args.length > 0
? message.args[0]
: 'Unknown error',
content: `Error occurred at ${message.pathname}${message.search}${message.hash}\nPort: ${message.port}\n\nStack trace:\n${cleanStackTrace(message.stack || '')}`, content: `Error occurred at ${message.pathname}${message.search}${message.hash}\nPort: ${message.port}\n\nStack trace:\n${cleanStackTrace(message.stack || '')}`,
source: 'preview', source: 'preview',
}); });