question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add async operation for ToHtml() method

See original GitHub issue

New Feature Proposal

Description

Add async operation for Node.ToHtml(TextWriter writer, IMarkupFormatter formatter) method.

Background

In AspNet Core 3.0, Synchronous IO is disallowed in default, AllowSynchronousIO disabled in all servers, this means if we call doc.ToHtml() in AspNet will throw an error: Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead.

AspNet code:

using (var writer = _writerFactory.CreateWriter(Response.Body, encoding){
    doc.ToHtml(writer);
    await writer.FlushAsync();
}

Specification

Wish to add new ToHtmlAsync() method for asynchronous IO operation or add new options for ToHtml() allows asynchronous write operation.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Tratchercommented, Apr 8, 2020

@zhengchun what’s the stack trace for the exception?

Writing to a MemoryStream should be fine, but flushing it out to the response body needs to be async.

0reactions
FlorianRapplcommented, Apr 10, 2020

Hi @Tratcher that’s certainly a good point. The average write here is about 4 to 16 characters dep. on the document. So we do not talk in ~1k (or more) chunks (which would benefit the specific IO). With small I refer to a single write unit in AngleSharp - which is way less than usual IO buffers used these days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

async function - JavaScript - MDN Web Docs - Mozilla
The async function declaration creates a binding of a new async function to a given name. The await keyword is permitted within the...
Read more >
Updating HTML inside async function - javascript
I suspect that async function doesn't stop on time when Updated content is requested. That is why I'm trying window.onload, but still not ......
Read more >
JavaScript Async
Let's go slowly and learn how to use it. Basic Syntax. async function myDisplay() { let myPromise = new Promise(function(resolve, reject) { resolve("I ......
Read more >
Asynchronous programming: futures, async, await
When you call an asynchronous function, it returns an uncompleted future. That future is waiting for the function's asynchronous operation to finish or...
Read more >
Using Asynchronous Methods in ASP.NET MVC 4
The async keyword represents a hint that you can use to mark methods as task-based asynchronous methods. The combination of await, async, and ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found