-
Notifications
You must be signed in to change notification settings - Fork 1.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
fix: 🐛 #2581 修复 scheduler 任务调度的问题 (#2581) #2582
Conversation
👋 @AricZhu 💖 Thanks for opening this pull request! 💖 Please follow the contributing guidelines. And we use semantic commit messages to streamline the release process. Examples of commit messages with semantic prefixes:
Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
@AricZhu Please provide us with more info about this pull request. |
Codecov Report
@@ Coverage Diff @@
## master #2582 +/- ##
=======================================
Coverage 40.76% 40.76%
=======================================
Files 542 542
Lines 32395 32395
Branches 6608 6608
=======================================
Hits 13207 13207
Misses 18396 18396
Partials 792 792
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@@ -17,7 +17,7 @@ export namespace Scheduler { | |||
const schedule = (cb: FlushTaskFn) => unit.push(cb) === 1 && postMessage() | |||
|
|||
const postMessage = (() => { | |||
const cb = () => unit.splice(0, unit.length).forEach((c) => c()) | |||
const cb = () => unit.splice(0, unit.length)[0]?.() |
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.
直接使用 unit.splice(0, 1).forEach((c) => c()) 比较好。
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.
这里不清空 unit 队列的话会有 bug,会导致任务超时被挂起后,后续就再也不会被触发了(schedule 中由于 unit 没有被清空,所以永远满足不了 length 为 1 的条件,后续的 postMessage 也就不会被调用)
👋 @AricZhu Congrats on merging your first pull request! 🎉🎉🎉 |
Description
Motivation and Context
Types of changes
Self Check before Merge