Uh oh!
There was an error while loading. Please reload this page.
Add async processing support to support async plugins - #682
Conversation
Resolvesremarkjs#680 Signed-off-by: Michael Irwin <mikesir87@gmail.com>
This comment was marked as resolved.
This comment was marked as resolved.
wooorm
commented
Apr 6, 2022
Thanks for the PR! Hmm, this seems to be a bit of a naïve attempt:
|
mikesir87
commented
Apr 6, 2022
Haha... very well might be! 😅 I tried quite a few ways to get something working that will be both backwards compatible and work for the async route.
My bad. I'll get on that. 😄 I did at least update the typings for the new attribute.
There wasn't any previous error handling in place if the processing failed for whatever reason. Sure, in this case, it'll be an uncaught exception thrown by a Promise. Recommendations on what you'd like to see here?
I can plug in a few tests to exercise this. I did add a test that at least exercises the async rendering (why I had to add
I'm not sure that's the case, as there's no event or callback mechanism to trigger the callback function. I actually started by running everything within a
Based on my limited experience, it does appear that server-side rendering is unsupported for My guessing is that, based on me having to use the |
Signed-off-by: Michael Irwin <mikesir87@gmail.com>
ebf016d to
bc044a7CompareSigned-off-by: Michael Irwin <mikesir87@gmail.com>
mikesir87
commented
Apr 6, 2022
Docs updated and added a simple async plugin to validate it both executes and the overall rendering still works. |
adamdotdevin
commented
May 21, 2022
Is this PR still alive? I'm also looking for async plugin support and wondering if this effort was ongoing. Happy to help if needed. |
wooorm
commented
May 21, 2022
There are still some more todos from #682 (comment) as I understand it. |
mikesir87
commented
May 21, 2022
As far as I'm aware (it's been a little while though), I addressed all of the concerns in the comment. However, I did find one additional bug... if the markdown changes (eg, you have a live editor or a component is reused with new markdown), the new markdown isn't rendered. That's the challenge of trying to use the same component for both async and synchronous work. One idea is to make a completely separate component that renders asynchronously, allowing me to use |
This is especially needed with the new react server components Since the component is built on server side, the component itself can be async (as highlighted here) thus allowing This also means that the server-side components cannot have 'useState', which means the PR probably needs to change to support server side components. |
wooorm
commented
Dec 2, 2022
Why?
What you link is Next.js-specific documentation, about their own API for pages and layouts, which indeed can be async, I think that was already possible, and I don’t see how that relates to React? |
This comment was marked as spam.
This comment was marked as spam.
ChristianMurphy
commented
Jul 19, 2023
@reypm you can find the status by reading the comments directly above yours. |
simonpfish
commented
Oct 17, 2023
Hey @wooorm@ChristianMurphy! How can I help land this PR? |
simonpfish
commented
Oct 17, 2023
We want to use a couple of async plugins in cookbook.openai.com, and this is currently blocking us. Happy to help iterate on it to be able to merge. |
wooorm
commented
Oct 17, 2023
See the comment before yours. There’s no way to do this yet, while the React RFCs aren‘t ready. @remcohaszing had an idea that could perhaps work but would need a ton of testing and probably still be a separate “experimental“ export. Use the |
simonpfish
commented
Oct 17, 2023
Got it! I ended up just using |
lovettbarron
commented
Jul 3, 2024
Is there any progress or blockers on this one? I've encountered it a few times now: initially with a plugin I'm developing, and now again with rehypejs/rehype-starry-night |
wooorm
commented
Jul 3, 2024
see the earlier comments please :) |
wooorm
commented
Sep 23, 2024
Investigated this for a bit last week, an |
PrinOrange
commented
Oct 17, 2024
How about the |
This comment was marked as spam.
This comment was marked as spam.
muhammadsr
commented
Feb 9, 2025
@simonpfish saved the day for me. Thanks |
This commit adds 2 new components that support turning markdown into react nodes, asynchronously. There are different ways to support async things in React. Component with hooks only run on the client. Components yielding promises are not supported on the client. To support different scenarios and the different ways the future could develop, these choices are made explicit to users. Users can choose whether `MarkdownAsync` or `MarkdownHooks` fits their use case. ClosesGH-680. ClosesGH-682.
This comment has been minimized.
This comment has been minimized.
wooorm
commented
Feb 20, 2025
Released in |
Resolves#680
Initial checklist
Description of changes
Added an
asyncoption to the component. If true, runs the renderer usingprocessor.runinstead ofprocessor.runSync(which causes an error be thrown).