Skip to content

Some plugins require async run #680

Closed

Description

@mikesir87

Initial checklist

Affected packages and versions

8.0.2

Link to runnable example

https://codesandbox.io/s/nice-austin-wrug0t

Steps to reproduce

  1. Install remark-code-frontmatter
  2. Install remark-code-extra
  3. Configure the component to use both plugins
  4. See error

Expected behavior

The render still works.

Actual behavior

When using the remark-code-frontmatter and remark-code-extra plugins, I'm getting the following error:

index.js:566 Uncaught (in promise) Error: `runSync` finished async. Use `run` instead
    at assertDone (index.js:566)
    at Function.runSync (index.js:352)
    at ReactMarkdown (react-markdown.js:107)
    at renderWithHooks (react-dom.development.js:14985)
    at mountIndeterminateComponent (react-dom.development.js:17811)
    at beginWork (react-dom.development.js:19049)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994)
    at invokeGuardedCallback (react-dom.development.js:4056)
    at beginWork$1 (react-dom.development.js:23964)

Digging in, it looks like the remark-code-extra plugin is returning Promises, forcing the async flow.

Runtime

No response

Package manager

No response

OS

No response

Build and bundle tools

No response

Activity

  1. added
    👋 phase/new
    🤞 phase/open
    and removed
    👋 phase/new
    on Apr 5, 2022
  2. wooorm commented on Apr 5, 2022

    @wooorm
    Member

    PR welcome!

  3. added
    👍 phase/yes
    on Apr 5, 2022
  4. removed
    🤞 phase/open
    on Apr 5, 2022
  5. github-actions commented on Apr 5, 2022

    @github-actions
  6. wooorm commented on Apr 5, 2022

    @wooorm
    Member

    Also, probably a very bad idea to use a plugin that hasn’t been updated in 3 years...

  7. mikesir87 commented on Apr 5, 2022

    @mikesir87
    Author

    Also, probably a very bad idea to use a plugin that hasn’t been updated in 3 years...

    Haha... very true. I saw that the plugins were referenced on the list of plugins and still indicated they were "up to date". I guess that means different things to different people! 😆

    I might take a stab at a PR, but maybe it's worth looking around to see if there are any newer plugins too. Thanks!

  8. added a commit that references this issue on Apr 6, 2022
    1d04e4a
  9. wooorm commented on Apr 6, 2022

    @wooorm
    Member

    That indication means that it did not start crashing when remark introduced a breaking change two 2 years ago, which did affect some plugins.

    maybe it's worth looking around to see if there are any newer plugins too

    Perhaps I can help you if I know what you are looking for?

  10. mikesir87 commented on Apr 6, 2022

    @mikesir87
    Author

    Perhaps I can help you if I know what you are looking for?

    I like the idea of using the remark-code-frontmatter plugin and loading additional metadata into the code snippets. My use case is displaying code snippets, but having additional metadata to enable various features (when to show a copy button, a sample filename to display, etc.). Combining that with the remark-code-extra has made it super simple to wrap the code blocks.

    FWIW... it's been working great and I haven't run into issues yet beyond needing the processor to run asynchronously. But, if there are other plugins you think can meet this need, I'll be happy to switch!

  11. ujjwalchadha8 commented on Dec 2, 2022

    @ujjwalchadha8

    This is definitely a blocker for many scenarios and going to be a bigger one once react server components are more common and people would wanna put async code in plugins.
    I've added more context on the PR

  12. wooorm commented on Dec 2, 2022

    @wooorm
    Member

    blocker for many scenarios

    Such as?

    once react server components are more common and people would wanna put async code in plugins

    Why? I don’t see how RSC affects this issue.

  13. ujjwalchadha8 commented on Dec 3, 2022

    @ujjwalchadha8

    Why? I don’t see how RSC affects this issue.

    I am trying to build a remark plugin which requires async run and use it in react markdown. I am using this in a React Server Component

    If this was a client-side component, I would have called the plugin in a hook (as a standalone remark plugin) and loaded the result in the react markdown plugin when the result was complete, allowing me to run the code synchronously

    Since this is a server-side component, the result needs to be compiled on the server and I cannot use hooks or state. It would make things easier if the component (ReactMarkdown) itself is made asynchronous, allowing it to use run instead of runSync for plugins.

    Such as?

    With RSC, more people are going to use ReactMarkdown to render markdown on server side instead of using other technologies because it integrates with their frontend well and it is easier to maintain it in a single codebase. In such cases, async plugins can potentially be more common. This is the exact same thing I am facing. I was previously rendering md on server side manually with some limited format options. Now I can just use ReactMarkdown with RSC

  14. 10 remaining items

  15. remcohaszing commented on Feb 13, 2024

    @remcohaszing
    Member

    I see. I remember we talked about it, but I didn’t see it in this issue and didn’t realize the idea was posted in that PR.

    Is a PR welcome for that, or is more discussion needed?

  16. wooorm commented on Feb 13, 2024

    @wooorm
    Member

    Yes, looking for someone to do the work and investigate whether it works or not.
    Not sure about the prop you mention here.
    And I believe it to be hard to test and dependent on undocumented/experimental features (reactjs/rfcs#229) so that’s why I think marking the API as experimental and unstable for now is a good idea.

  17. programming-with-ia commented on Sep 5, 2024

    @programming-with-ia
  18. programming-with-ia commented on Sep 5, 2024

    @programming-with-ia
  19. liuhq commented on Nov 7, 2024

    @liuhq

    also the async problem from using shiki that is a code highlighter -> https://shiki.matsu.io/packages/rehype

  20. x5engine commented on Nov 29, 2024

    @x5engine
  21. x5engine commented on Dec 2, 2024

    @x5engine
  22. ChristianMurphy commented on Dec 2, 2024

    @ChristianMurphy
    Member

    @x5engine this package is still actively maintained, and many plugins are supported.
    If you have questions on how to use a specific plugin feel free to ask in the forum https://github.com/orgs/remarkjs/discussions
    If you would like to accelerate this feature by contributing, some ideas are outlined in #680 (comment)

    Comments focused on attacking maintainers here and on other threads are unhelpful, unwelcome, and against the code of conduct (CoC) https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
    Take a week to cool off, if you continue to break the CoC further actions, including a permanent ban from being able to access support channels could follow.

  23. added a commit that references this issue on Feb 14, 2025
    8128a21
  24. added a commit that references this issue on Feb 20, 2025
    6ce120e
  25. github-actions commented on Feb 20, 2025

    @github-actions
  26. removed
    👍 phase/yes
    on Feb 20, 2025
  27. wooorm commented on Feb 20, 2025

    @wooorm
    Member

    Released in 9.1.0!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    💪 phase/solved

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions