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(scheduler): prevent duplicate jobs being queued #11826

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

skirtles-code
Copy link
Contributor

@skirtles-code skirtles-code commented Sep 5, 2024

Fixes #11712
Fixes #11807

I still need to write some tests for this, but the existing tests pass.

A job should only appear in the active part of the scheduler queue once. Currently it can be added multiple times, with the job being added again every time a reactive dependency changes.

The QUEUED flag should be set for all jobs that are currently in the queue, not just those with a particular value for ALLOW_RECURSE.

The ALLOW_RECURSE flag is only relevant if a job is re-queued while that same job is currently running. Here I've implemented that by clearing the flag QUEUED immediately prior to running the job if ALLOW_RECURSE is set. Otherwise the flag is cleared after the job runs.

It isn't clear to me how errors should be handled. For the main queue, I assume the QUEUED flags all need to be unset in the finally block, as an error may have been thrown during flushing that prevented some of the flags being unset. For the post queue there doesn't seem to be equivalent error handling and I'm not sure if that should be added.

Copy link

github-actions bot commented Sep 5, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 100 kB (+103 B) 37.8 kB (+21 B) 34 kB (+21 B)
vue.global.prod.js 159 kB (+103 B) 57.6 kB (+20 B) 51.2 kB (-19 B)

Usages

Name Size Gzip Brotli
createApp 55.3 kB (+103 B) 21.3 kB (+24 B) 19.4 kB (-39 B)
createSSRApp 59.3 kB (+103 B) 22.9 kB (+25 B) 20.9 kB (-12 B)
defineCustomElement 60 kB (+103 B) 22.8 kB (+24 B) 20.8 kB (+65 B)
overall 69.1 kB (+103 B) 26.4 kB (+24 B) 24 kB (+21 B)

Copy link

pkg-pr-new bot commented Sep 5, 2024

Open in Stackblitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@11826

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@11826

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@11826

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@11826

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@11826

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@11826

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@11826

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@11826

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@11826

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@11826

vue

pnpm add https://pkg.pr.new/vue@11826

commit: c23c01f

@yyx990803
Copy link
Member

Great work, I'll get this released in a patch, let's follow up with a test case later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants