refactor: optimize error handling and npm install performance

Remove redundant error type handling in webcontainer to simplify logic and improve maintainability. Additionally, comment out lock file patterns to speed up npm install process.
This commit is contained in:
KevIsDev 2025-05-10 13:24:08 +01:00
parent 9a5076d8c6
commit 9a748177ef
3 changed files with 7 additions and 19 deletions

View File

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

View File

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

View File

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