kontent-ai / delivery-sdk-js

Kontent Delivery SDK for Javascript
https://kontent.ai
MIT License
50 stars 34 forks source link

Exponential rendering time using `createRichTextObjectResolver` #374

Open Piwaii opened 1 year ago

Piwaii commented 1 year ago

Brief bug description

We are rendering a big article with markup (56000 characters) using createRichTextObjectResolver and it takes more than 25 seconds to answer.

Repro steps

  1. Create a big rich text article with markup (more than 50000 characters)
  2. Try to render it with createRichTextObjectResolver
  3. See error or too much time to render

Expected behavior

Event if it's a big article, it should render in a reasonable time (avoiding possible timeouts)

Test environment

Additional context

We tested it in a little project (repo can be shared on demand) and the results are these :

Simply007 commented 1 year ago

Sorry to hear that @Piwaii,

Can you provide the data you used for the testing? I am interested in the complexity of the input.

We are currently working on the replacement for rich text resolution to unify the capabilities. Would you be willing to try to render your data using Ritch text resolver?

An example of use could be seen in the README of the linked repository, or on https://github.com/Simply007/kontent-starter-corporate-next-js/blob/main/src/components/RichText.js.

Piwaii commented 1 year ago

Indeed this new lib is very efficient :

rendering 74730 characters
  - before was resolved in 22271ms with createRichTextObjectResolver()
  - now is resolved in 8ms with nodeParse()

we will definitely follow this new repo :)

thank you very much @Simply007

Simply007 commented 1 year ago

Thanks for sharing the result! It looks awesome.

Parsing seems very efficient. Have you just parsed the input, or also used the resolution library (i,e, linked https://www.npmjs.com/package/@portabletext/react)?

Piwaii commented 1 year ago

We measured only the parsing

davshoward commented 11 months ago

An example of use could be seen in the README of the linked repository, or on https://github.com/Simply007/kontent-starter-corporate-next-js/blob/main/src/components/RichText.js.

This is great - thank you. Is there an example of this using TypeScript? Adds an extra layer of complexity :-p

Enngage commented 10 months ago

I'm looking into implementing a simpler (RegEx & replace) based solution in this SDK as a replacement for the browser / parse5 parser that this SDK currently uses. I've implemented it in another project already and saw a huge improvement in speed.. what took 1 minute using the node.js parser now takes under a second in new implementation.

I'm hoping to look into this in near future, but can't promise anything just yet ;)