Skip to content

Add a Task.abort() method#3998

Merged
justinfagnani merged 8 commits intomainfrom
task-abort
Jul 7, 2023
Merged

Add a Task.abort() method#3998
justinfagnani merged 8 commits intomainfrom
task-abort

Conversation

@justinfagnani
Copy link
Collaborator

Fixes #3997

This makes task cancellation possible, but manual. It's maybe desirable in some cases to somehow allow passing an AbortSignal into the task and composing it with the signal we automatically create, and but the exact requirements and shape of that API aren't clear yet. Chaining tasks is one of the more obvious use cases, but this might be doable already because aborting a task will reject its taskComplete promise, which can be passed to downstream tasks.

@justinfagnani justinfagnani requested a review from rictic July 7, 2023 02:17
@changeset-bot
Copy link

changeset-bot bot commented Jul 7, 2023

🦋 Changeset detected

Latest commit: 92bd660

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@lit-labs/task Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Jul 7, 2023

📊 Tachometer Benchmark Results

Summary

nop-update

  • lit-html-kitchen-sink: unsure 🔍 -13% - +7% (-3.47ms - +1.88ms)
    this-change vs tip-of-tree

render

  • lit-element-list: 81.58ms - 85.93ms
  • lit-html-kitchen-sink: unsure 🔍 -10% - +7% (-3.60ms - +2.53ms)
    this-change vs tip-of-tree
  • lit-html-repeat: unsure 🔍 -4% - +3% (-0.43ms - +0.34ms)
    this-change vs tip-of-tree
  • lit-html-template-heavy: unsure 🔍 -4% - +1% (-2.78ms - +0.44ms)
    this-change vs tip-of-tree
  • reactive-element-list: unsure 🔍 -5% - +0% (-2.74ms - +0.13ms)
    this-change vs tip-of-tree

update

  • lit-element-list: 932.61ms - 945.64ms
  • lit-html-kitchen-sink: unsure 🔍 -8% - +3% (-8.24ms - +2.79ms)
    this-change vs tip-of-tree
  • lit-html-repeat: unsure 🔍 -5% - +3% (-16.60ms - +11.62ms)
    this-change vs tip-of-tree
  • lit-html-template-heavy: unsure 🔍 -1% - +4% (-0.69ms - +5.23ms)
    this-change vs tip-of-tree
  • reactive-element-list: unsure 🔍 -1% - +0% (-14.02ms - +3.94ms)
    this-change vs tip-of-tree

update-reflect

  • lit-element-list: 880.91ms - 893.67ms
  • reactive-element-list: unsure 🔍 -1% - +1% (-10.13ms - +7.46ms)
    this-change vs tip-of-tree

Results

lit-element-list

render

VersionAvg timevs
81.58ms - 85.93ms-

update

VersionAvg timevs
932.61ms - 945.64ms-

update-reflect

VersionAvg timevs
880.91ms - 893.67ms-
lit-html-kitchen-sink

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
34.06ms - 38.57ms-unsure 🔍
-10% - +7%
-3.60ms - +2.53ms
unsure 🔍
-13% - +4%
-4.93ms - +1.51ms
tip-of-tree
tip-of-tree
34.77ms - 38.92msunsure 🔍
-7% - +10%
-2.53ms - +3.60ms
-unsure 🔍
-11% - +5%
-4.27ms - +1.92ms
previous-release
previous-release
35.72ms - 40.33msunsure 🔍
-4% - +14%
-1.51ms - +4.93ms
unsure 🔍
-5% - +12%
-1.92ms - +4.27ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
93.13ms - 98.31ms-unsure 🔍
-8% - +3%
-8.24ms - +2.79ms
unsure 🔍
-3% - +4%
-2.49ms - +4.24ms
tip-of-tree
tip-of-tree
93.58ms - 103.31msunsure 🔍
-3% - +9%
-2.79ms - +8.24ms
-unsure 🔍
-2% - +9%
-1.72ms - +8.92ms
previous-release
previous-release
92.69ms - 97.00msunsure 🔍
-4% - +3%
-4.24ms - +2.49ms
unsure 🔍
-9% - +2%
-8.92ms - +1.72ms
-

nop-update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
24.58ms - 28.35ms-unsure 🔍
-13% - +7%
-3.47ms - +1.88ms
unsure 🔍
-13% - +5%
-3.57ms - +1.33ms
tip-of-tree
tip-of-tree
25.36ms - 29.16msunsure 🔍
-7% - +13%
-1.88ms - +3.47ms
-unsure 🔍
-10% - +8%
-2.78ms - +2.13ms
previous-release
previous-release
26.02ms - 29.15msunsure 🔍
-5% - +14%
-1.33ms - +3.57ms
unsure 🔍
-8% - +10%
-2.13ms - +2.78ms
-
lit-html-repeat

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
11.47ms - 11.91ms-unsure 🔍
-4% - +3%
-0.43ms - +0.34ms
unsure 🔍
-5% - +2%
-0.62ms - +0.20ms
tip-of-tree
tip-of-tree
11.42ms - 12.05msunsure 🔍
-3% - +4%
-0.34ms - +0.43ms
-unsure 🔍
-5% - +3%
-0.64ms - +0.30ms
previous-release
previous-release
11.55ms - 12.25msunsure 🔍
-2% - +5%
-0.20ms - +0.62ms
unsure 🔍
-3% - +5%
-0.30ms - +0.64ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
348.88ms - 369.65ms-unsure 🔍
-5% - +3%
-16.60ms - +11.62ms
unsure 🔍
-4% - +4%
-12.83ms - +13.37ms
tip-of-tree
tip-of-tree
352.21ms - 371.31msunsure 🔍
-3% - +5%
-11.62ms - +16.60ms
-unsure 🔍
-3% - +4%
-9.69ms - +15.21ms
previous-release
previous-release
351.01ms - 366.98msunsure 🔍
-4% - +4%
-13.37ms - +12.83ms
unsure 🔍
-4% - +3%
-15.21ms - +9.69ms
-
lit-html-template-heavy

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
60.56ms - 62.72ms-unsure 🔍
-4% - +1%
-2.78ms - +0.44ms
unsure 🔍
-3% - +1%
-2.13ms - +0.86ms
tip-of-tree
tip-of-tree
61.62ms - 64.00msunsure 🔍
-1% - +5%
-0.44ms - +2.78ms
-unsure 🔍
-2% - +3%
-1.04ms - +2.11ms
previous-release
previous-release
61.25ms - 63.31msunsure 🔍
-1% - +3%
-0.86ms - +2.13ms
unsure 🔍
-3% - +2%
-2.11ms - +1.04ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
138.42ms - 142.97ms-unsure 🔍
-1% - +4%
-0.69ms - +5.23ms
unsure 🔍
-2% - +2%
-2.37ms - +3.48ms
tip-of-tree
tip-of-tree
136.53ms - 140.31msunsure 🔍
-4% - +0%
-5.23ms - +0.69ms
-unsure 🔍
-3% - +1%
-4.34ms - +0.92ms
previous-release
previous-release
138.30ms - 141.97msunsure 🔍
-2% - +2%
-3.48ms - +2.37ms
unsure 🔍
-1% - +3%
-0.92ms - +4.34ms
-
reactive-element-list

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
52.31ms - 53.74ms-unsure 🔍
-5% - +0%
-2.74ms - +0.13ms
unsure 🔍
-3% - +1%
-1.52ms - +0.70ms
tip-of-tree
tip-of-tree
53.08ms - 55.57msunsure 🔍
-0% - +5%
-0.13ms - +2.74ms
-unsure 🔍
-1% - +5%
-0.62ms - +2.40ms
previous-release
previous-release
52.58ms - 54.29msunsure 🔍
-1% - +3%
-0.70ms - +1.52ms
unsure 🔍
-4% - +1%
-2.40ms - +0.62ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
973.87ms - 986.44ms-unsure 🔍
-1% - +0%
-14.02ms - +3.94ms
unsure 🔍
-2% - +0%
-18.45ms - +0.49ms
tip-of-tree
tip-of-tree
978.78ms - 991.61msunsure 🔍
-0% - +1%
-3.94ms - +14.02ms
-unsure 🔍
-1% - +1%
-13.50ms - +5.62ms
previous-release
previous-release
982.04ms - 996.23msunsure 🔍
-0% - +2%
-0.49ms - +18.45ms
unsure 🔍
-1% - +1%
-5.62ms - +13.50ms
-

update-reflect

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
946.93ms - 959.51ms-unsure 🔍
-1% - +1%
-10.13ms - +7.46ms
unsure 🔍
-1% - +1%
-11.49ms - +6.90ms
tip-of-tree
tip-of-tree
948.41ms - 960.70msunsure 🔍
-1% - +1%
-7.46ms - +10.13ms
-unsure 🔍
-1% - +1%
-10.05ms - +8.13ms
previous-release
previous-release
948.82ms - 962.22msunsure 🔍
-1% - +1%
-6.90ms - +11.49ms
unsure 🔍
-1% - +1%
-8.13ms - +10.05ms
-

tachometer-reporter-action v2 for Benchmarks

@rictic
Copy link
Collaborator

rictic commented Jul 7, 2023

Oh good catch (he he) with undefined error values!

@justinfagnani
Copy link
Collaborator Author

@rictic yeah, that really through me for a loop for a while today. Only found it because I was aborting with undefined only in Safari 14 because it didn't support signal.reason, and the task wasn't transitioning to ERROR in that case. I have a bruise on my head from banging it 🤕

@justinfagnani justinfagnani merged commit 937f4e9 into main Jul 7, 2023
@justinfagnani justinfagnani deleted the task-abort branch July 7, 2023 23:29
@lit-robot lit-robot mentioned this pull request Aug 2, 2023
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.

[labs/task] Allow tasks to be canceled

2 participants