CompilePdfAsync(string outputFile, ..., CancellationToken) (TypstCompiler.cs:420):
using var document = CompileToDocument("pdf", pdfStandards: pdfStandards);
await document.WriteOutputToFileAsync(outputFile, cancellationToken: cancellationToken).ConfigureAwait(false);
CompileToDocument is a blocking P/Invoke, so the compile runs synchronously on the calling thread before the first await, and the token reaches only the file write. The stream overload (:453) has the same shape. The XML doc says "Asynchronously compiles the Typst document".
Two consequences. The async overloads hold a thread-pool thread for the whole compile instead of yielding, so callers who chose them to avoid that get no benefit. And a cancelled request reclaims nothing: RequestAborted or a Kestrel timeout fires, the token is observed only after the compile has finished, and the work runs to completion. Typst caps while at 10,000 iterations but not for over a large range, so the duration is unbounded.
What I would like:
- Correct the XML docs and README: compilation is synchronous and CPU-bound, the async overloads cover only the output write, and the token does not cancel the compile.
- An overload that runs the compile on the thread pool and honours the token before starting, so the caller's thread is released.
CompilePdfAsync(string outputFile, ..., CancellationToken)(TypstCompiler.cs:420):CompileToDocumentis a blocking P/Invoke, so the compile runs synchronously on the calling thread before the firstawait, and the token reaches only the file write. The stream overload (:453) has the same shape. The XML doc says "Asynchronously compiles the Typst document".Two consequences. The async overloads hold a thread-pool thread for the whole compile instead of yielding, so callers who chose them to avoid that get no benefit. And a cancelled request reclaims nothing:
RequestAbortedor a Kestrel timeout fires, the token is observed only after the compile has finished, and the work runs to completion. Typst capswhileat 10,000 iterations but notforover a large range, so the duration is unbounded.What I would like: