Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: always return promise if async #2728

Merged
merged 4 commits into from
Mar 22, 2023
Merged

Conversation

UziTech
Copy link
Member

@UziTech UziTech commented Feb 4, 2023

Marked version: 4.2.12

Description

Always return a promise if async option is true.

Contributor

  • Test(s) exist to ensure functionality and minimize regression (if no tests added, list tests covering this PR); or,
  • no tests required for this PR.
  • If submitting new feature, it has been documented in the appropriate places.

Committer

In most cases, this should be a different person than the contributor.

@vercel
Copy link

vercel bot commented Feb 4, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
marked-website ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 5, 2023 at 3:50PM (UTC)

+ escape(e.message + '', true)
+ '</pre>';
if (opt.async) {
return Promise.reject(msg);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s unusual to reject with a string. Usually it’s an Error

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in silent mode so maybe we should actually resolve with the string?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the string is returned in silent mode instead of thrown

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated it to resolve on silent and reject with error when not in silent mode. This seems to be the closest async equivalent to what happens when synchronous.

docs/USING_PRO.md Outdated Show resolved Hide resolved
Co-authored-by: Steven <steven@ceriously.com>
Copy link
Member

@styfle styfle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

@UziTech UziTech merged commit 042dcc5 into markedjs:master Mar 22, 2023
github-actions bot pushed a commit that referenced this pull request Mar 22, 2023
# [4.3.0](v4.2.12...v4.3.0) (2023-03-22)

### Bug Fixes

* always return promise if async ([#2728](#2728)) ([042dcc5](042dcc5))
* fenced code doesn't need a trailing newline ([#2756](#2756)) ([3acbb7f](3acbb7f))

### Features

* add preprocess and postprocess hooks ([#2730](#2730)) ([9b452bc](9b452bc))
@UziTech UziTech deleted the fix-async branch August 26, 2023 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

async: true inconsistent return type (Promise | string) + docs update
2 participants