Skip to content

Commit 12c5ace

Browse files
committed
Deno.stderr.writeSync() may not wright full error message buffer in one go for very long message
Error in Jupyter Notebook can have very long backtrace which where truncated in console logger, but not in file logger. Context #12238
1 parent e7809ce commit 12c5ace

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

news/changelog-1.7.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ All changes included in 1.7:
146146
- ([#11803](https://github.com/quarto-dev/quarto-cli/pull/11803)): Added a new CLI command `quarto call`. First users of this interface are the new `quarto call engine julia ...` subcommands.
147147
- ([#12338](https://github.com/quarto-dev/quarto-cli/issues/12338)): Add an additional workaround for the SCSS parser used in color variable extraction.
148148
- ([#12369](https://github.com/quarto-dev/quarto-cli/pull/12369)): `quarto preview` correctly throws a YAML validation error when a `format` key does not conform.
149+
- ([#12238](https://gijit.com/quarto-dev/quarto-cli/issues/12238)): Very long error (e.g. in Jupyter Notenook with backtrace) are now no more truncated in the console.
149150

150151
## Languages
151152

src/core/log.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,23 @@ export class StdErrOutputHandler extends BaseHandler {
156156
return msg;
157157
}
158158
log(msg: string): void {
159-
Deno.stderr.writeSync(
160-
new TextEncoder().encode(msg),
161-
);
159+
const encoder = new TextEncoder();
160+
const data = encoder.encode(msg);
161+
162+
let bytesWritten = 0;
163+
while (bytesWritten < data.length) {
164+
// Write the remaining portion of the buffer
165+
const remaining = data.subarray(bytesWritten);
166+
const written = Deno.stderr.writeSync(remaining);
167+
168+
// If we wrote 0 bytes, something is wrong - avoid infinite loop
169+
if (written === 0) {
170+
// Could add fallback handling here if needed
171+
break;
172+
}
173+
174+
bytesWritten += written;
175+
}
162176
}
163177
}
164178

0 commit comments

Comments
 (0)