-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
prevent a try catch from hiding a build error, also fix build/emoji.js in Windows #2291
Open
trusktr
wants to merge
4
commits into
develop
Choose a base branch
from
unhide-build-errors
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4f62eb8
prevent a try catch from hiding a build error
trusktr 505b685
take into account possible CRLF endings in the regex in build/emoji.j…
trusktr 76334a9
Merge branch 'develop' into unhide-build-errors
Koooooo-7 a602b60
Merge branch 'develop' into unhide-build-errors
trusktr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@trusktr --
getEmojiData()
makes an API call to check if new emoji data is available and update Docsify if necessary. A failed API call does not warrant a broken build (it just means a check for new Emoji data won't occur). This is what thetry/catch
was in place for.We can replace the
try/catch
with something else, but the failed API call should be handled gracefully.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why should this succeedd if the API call fails? What's the reasoning?
If this exits zero despite it failing, then other scripts in a pipeline will happily continue along and an issue may go unnoticed. It seems better to not have unintentionally incorrect builds.
What if, for example, we are publishing, and the emoji build fails, and the published package is not up to date because we thought it worked?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this as a simple solution:
build:emoji
from thebuild
script inpackage.json
build:emoji
to theprepare
script inpackage.json
build/emoji.js
Answers to your questions below...
The original goals were:
build
script.Remember, the API call is not required to complete a build. This is by design. We do not want our build to be reliant on a remote API that we do not control, which is why emoji data is stored in
src/core/render/emoji-data.js
. The API call simply checks to see if new data is available and, if so, updates theemoji-data.js
file which is used to generate distributable files in/lib/
. If the API call fails, the build will complete successfully using the data fromemoji-data.js
, which is the data stored in our repo and obtained from the last successful API call.Builds won't be "incorrect". Builds will contain "unchanged" emoji data because they will use local emoji data from
src/core/render/emoji-data.js
.The result would be that the emoji data used in the newly published package would be identical to the data used in the previously published package.
You make a good point though. We should not rely on developers noticing an error message in the console to ensure our emoji updates are working as expected. See proposed solution at the top of this message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was exiting zero, I made it exit non-zero. I don't believe any failure should be silenced.
Moving it to publish script (and publish script failing if the API fails) might be better.
We're doing that with
npm install
, relying on some remote server. Same difference. If the build isn't working, I want to know. Up until now (thanks to Windows), I never knew I was possibly missing failed emoji-data build.The API failure is intermittent, so it is also easy to click the button to re-run failed jobs. The main difference between that and publish script is someone will encounter the issue at a different point less often with a publish script (PRs with builds happening more often than when we publish), but we still want to know of issues (just like we want to know if
npm install
failed).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is that? Will someone try to use an emoji from GitHub that they thought would also work in Docsify but it is missing? If so, I'd say we don't want that, under the premise that the Docsify feature fully works.
If we really want to silence the failure of the API (and sometimes fail to support some emojis?) let's catch that specific failure but not silence the whole script (we want other non-API failures to still fail).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Koooooo-7 --
Let's just do this part (and skip the rest):
It's worth mentioning that this approach means it's possible that a new release could be published without the latest updates, but it's highly unlikely. The only two scenarios that would cause this to happen are if we publish a new release when 1) new emoji data is available but our daily emoji update workflow has not run or 2) we ignore an existing emoji update PR.
That works for me. @trusktr? @sy-records?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main reason that raised this issue is that the script failed for a reason unrelated to the emoji API, because all errors in the file were supressed. Just want to make this part obvious because it wasn't covered in your reply.
(Side note, the API sometimes fails even if we have internet, due to an API error from GitHub)
I understand that the emoji-data will be unchanged if the script fails. But if GitHub introduces a new emoji
:whatever:
, and if a user tries to use that new:whatever:
emoji but Docsify doesn't render the emoji because the URL is not in that data file, and we release a Docsify update, then the feature could be considered to be partially not working as expected (that's ok, but not the best).Here in this file:
https://github.com/docsifyjs/docsify/blob/8ef9a3cd036bc86278709199e1da19da36f04ed1/src/core/render/emojify.js
We can see that it will only process emojis that exist in the emoji-data list. We can also see that Docsify is relying on GitHub as source of truth for names for native emojis based on unicode characters that the API sends back.
(On a related note, if GitHub removes an emoji (unlikely I imagine?) we might also want to show a warning if someone is still using it.)
Based on this, and on
perhaps we should
The only people running the release is one or two of us, so I think it is totally fine if it fails and we try again. We can automate it later if really needed but I don't think it is necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we choose to maintain the emojis in our side and sync it from github in every release, it always has the gap that we may miss some latest updated emojis until we do the next release. If we need keep the emoji in real time, we need go back to the beginning solution that concat the emoji directly... 😅
I think the
emoji plugin
solution is good.Base on the emoji plugin , we could support
mount
the emojiData instead of keeping it inside (bind the release of docsify itself). Then, if we rotate theemojiData
in theemoji plugin
on time and do the plugin release asap, it should be more likely up-to-date.But if users use something like
emoji-plugin@v5
, it goes back to the same issue tho...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to wrap this up. Way too much time has been spent on this seven month old , arguably low-priority ~10 line change that could be spent on far more impactful PRs.
Moving to an emoji plugin as described in #2431 is not an option for v5. This is why I added "This is a post-v5 feature request (see Milestone)" to the top of the issue when I created it earlier today. v5 needs to be v4 compatible (minus legacy browser support) for all of the reasons we have discussed previously. We can explore #2431 and other breaking options after v5 is released.
The solution proposed in #2291 (comment) addresses the issue described in this PR and all of the concerns shared above. It sounds like @Koooooo-7 is willing to work on it (correct?). If there is a better solution, let's hear it. If not, let's proceed with automating emoji updates via a daily workflow so we all can move on to other tasks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I may raise a PR for the daily upgrade auto check workflow first, and if we all agree to do it so. we can merge it and set it up to work.