mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-06 02:30:47 -08:00
fix: show wiki server error by hide view
This commit is contained in:
parent
ca0e720294
commit
5aa3ed7545
2 changed files with 59 additions and 31 deletions
|
|
@ -241,6 +241,15 @@ export class Wiki implements IWikiService {
|
|||
function: 'startWiki',
|
||||
});
|
||||
await workspaceService.updateMetaData(workspaceID, { isLoading: false, didFailLoadErrorMessage: errorMessage });
|
||||
|
||||
// For plugin errors that occur after wiki boot, realign the view to hide it and show error message
|
||||
const isPluginError = message.source === 'plugin-error';
|
||||
if (isPluginError && workspace.active) {
|
||||
const workspaceViewService = container.get<IWorkspaceViewService>(serviceIdentifier.WorkspaceView);
|
||||
await workspaceViewService.realignActiveWorkspace(workspaceID);
|
||||
logger.info('Realigned view after plugin error', { workspaceID, function: 'startWiki' });
|
||||
}
|
||||
|
||||
// fix "message":"listen EADDRINUSE: address already in use 0.0.0.0:5212"
|
||||
if (errorMessage.includes('EADDRINUSE')) {
|
||||
const portChange = {
|
||||
|
|
@ -253,7 +262,11 @@ export class Wiki implements IWikiService {
|
|||
reject(new WikiRuntimeError(new Error(message.message), wikiFolderLocation, true, { ...workspace, ...portChange }));
|
||||
return;
|
||||
}
|
||||
reject(new WikiRuntimeError(new Error(message.message), wikiFolderLocation, false, { ...workspace }));
|
||||
|
||||
// For plugin errors, don't reject - let user see the error and try to recover
|
||||
if (!isPluginError) {
|
||||
reject(new WikiRuntimeError(new Error(message.message), wikiFolderLocation, false, { ...workspace }));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,37 +38,52 @@ export function startNodeJSWiki({
|
|||
userName,
|
||||
workspace,
|
||||
}: IStartNodeJSWikiConfigs): Observable<IWikiMessage> {
|
||||
// Wait for services to be ready before using intercept with logFor
|
||||
onWorkerServicesReady(() => {
|
||||
void native.logFor(workspace.name, 'info', 'test-id-WorkerServicesReady');
|
||||
const textDecoder = new TextDecoder();
|
||||
intercept(
|
||||
(newStdOut: string | Uint8Array) => {
|
||||
const message = typeof newStdOut === 'string' ? newStdOut : textDecoder.decode(newStdOut);
|
||||
// Send to main process logger if services are ready
|
||||
void native.logFor(workspace.name, 'info', message).catch((error: unknown) => {
|
||||
console.error('[intercept] Failed to send stdout to main process:', error, message, JSON.stringify(workspace));
|
||||
});
|
||||
return message;
|
||||
},
|
||||
(newStdError: string | Uint8Array) => {
|
||||
const message = typeof newStdError === 'string' ? newStdError : textDecoder.decode(newStdError);
|
||||
// Send to main process logger if services are ready
|
||||
void native.logFor(workspace.name, 'error', message).catch((error: unknown) => {
|
||||
console.error('[intercept] Failed to send stderr to main process:', error, message);
|
||||
});
|
||||
return message;
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
if (openDebugger === true) {
|
||||
inspector.open();
|
||||
inspector.waitForDebugger();
|
||||
// eslint-disable-next-line no-debugger
|
||||
debugger;
|
||||
}
|
||||
return new Observable<IWikiMessage>((observer) => {
|
||||
if (openDebugger === true) {
|
||||
inspector.open();
|
||||
inspector.waitForDebugger();
|
||||
// eslint-disable-next-line no-debugger
|
||||
debugger;
|
||||
}
|
||||
// Wait for services to be ready before using intercept with logFor
|
||||
onWorkerServicesReady(() => {
|
||||
void native.logFor(workspace.name, 'info', 'test-id-WorkerServicesReady');
|
||||
const textDecoder = new TextDecoder();
|
||||
intercept(
|
||||
(newStdOut: string | Uint8Array) => {
|
||||
const message = typeof newStdOut === 'string' ? newStdOut : textDecoder.decode(newStdOut);
|
||||
// Send to main process logger if services are ready
|
||||
void native.logFor(workspace.name, 'info', message).catch((error: unknown) => {
|
||||
console.error('[intercept] Failed to send stdout to main process:', error, message, JSON.stringify(workspace));
|
||||
});
|
||||
return message;
|
||||
},
|
||||
(newStdError: string | Uint8Array) => {
|
||||
const message = typeof newStdError === 'string' ? newStdError : textDecoder.decode(newStdError);
|
||||
// Send to main process logger if services are ready
|
||||
void native.logFor(workspace.name, 'error', message).catch((error: unknown) => {
|
||||
console.error('[intercept] Failed to send stderr to main process:', error, message);
|
||||
});
|
||||
|
||||
// Detect critical plugin loading errors that can cause white screen
|
||||
// These errors occur during TiddlyWiki boot module execution
|
||||
if (
|
||||
message.includes('Error executing boot module') ||
|
||||
message.includes('Cannot find module')
|
||||
) {
|
||||
observer.next({
|
||||
type: 'control',
|
||||
source: 'plugin-error',
|
||||
actions: WikiControlActions.error,
|
||||
message,
|
||||
argv: [],
|
||||
});
|
||||
}
|
||||
|
||||
return message;
|
||||
},
|
||||
);
|
||||
});
|
||||
let fullBootArgv: string[] = [];
|
||||
// mark isDev as used to satisfy lint when not needed directly
|
||||
void isDev;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue