diff --git a/app/MindWork AI Studio/Tools/PandocExport.cs b/app/MindWork AI Studio/Tools/PandocExport.cs index acc4dbd6..3461e440 100644 --- a/app/MindWork AI Studio/Tools/PandocExport.cs +++ b/app/MindWork AI Studio/Tools/PandocExport.cs @@ -80,11 +80,18 @@ public static class PandocExport return false; } + // Read output streams asynchronously while the process runs (prevents deadlock): + var outputTask = process.StandardOutput.ReadToEndAsync(); + var errorTask = process.StandardError.ReadToEndAsync(); + + // Wait for the process to exit AND for streams to be fully read: await process.WaitForExitAsync(); + await outputTask; + var error = await errorTask; + if (process.ExitCode is not 0) { - var error = await process.StandardError.ReadToEndAsync(); - LOGGER.LogError($"Pandoc failed with exit code {process.ExitCode}: {error}"); + LOGGER.LogError("Pandoc failed with exit code {ProcessExitCode}: '{ErrorText}'", process.ExitCode, error); await MessageBus.INSTANCE.SendError(new(Icons.Material.Filled.Cancel, TB("Error during Microsoft Word export"))); return false; } diff --git a/app/MindWork AI Studio/wwwroot/changelog/v0.9.55.md b/app/MindWork AI Studio/wwwroot/changelog/v0.9.55.md index cc056442..b1d241b0 100644 --- a/app/MindWork AI Studio/wwwroot/changelog/v0.9.55.md +++ b/app/MindWork AI Studio/wwwroot/changelog/v0.9.55.md @@ -6,4 +6,6 @@ - Improved the document preview dialog for the document analysis assistant (in preview), providing Markdown and plain text views for attached files. - Improved the ID handling for configuration plugins. - Improved error handling, logging, and code quality. -- Fixed a bug in the local data sources info dialog (preview feature) for data directories that could cause the app to crash. The error was caused by a background thread producing data while the frontend attempted to display it. \ No newline at end of file +- Improved error handling for Microsoft Word export. +- Fixed a bug in the local data sources info dialog (preview feature) for data directories that could cause the app to crash. The error was caused by a background thread producing data while the frontend attempted to display it. +- Fixed a rare bug in the Microsoft Word export for huge documents. \ No newline at end of file