mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-26 18:26:38 +00:00
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:
parent
9a5076d8c6
commit
9a748177ef
@ -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',
|
||||
];
|
||||
|
||||
|
@ -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',
|
||||
];
|
||||
|
||||
|
@ -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',
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user