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

[task] It shouldn't be possible to assign status from outside #4550

Open
jrencz opened this issue Feb 13, 2024 · 1 comment · May be fixed by #4552
Open

[task] It shouldn't be possible to assign status from outside #4550

jrencz opened this issue Feb 13, 2024 · 1 comment · May be fixed by #4552

Comments

@jrencz
Copy link

jrencz commented Feb 13, 2024

Which package(s) are affected?

Task (@lit/task)

Description

I noticed that it's possible to set the status of a task manually, from outside, not via args, but just by assigning a value to task.status.

As long as the value is valid TaskStatus (let's say: TaskStatus.ERROR), it will result in rendering using expected renderer, but

  • only on a following update (unless this.requestUpdate() is called as well:
     this.task.status = TaskStatus.ERROR
     this.requestUpdate();
  • onError of the task won't run
  • taskComplete promise won't be rejected

I think this is a bug and that status should be reimplemented as a getter so it's not possible to set state from outside.

It is potentially a breaking change - users might have already started exploiting that behaviour in case there's neither onError nor one uses taskComplete rejections

Reproduction

repro

Demo shows that it's possible to make task render with error renderer 2 ways

  • one way that's arguably "correct", one that will make onError run and will make taskComplete promise get rejected,
  • one way that's IMO wrong and shouldn't be allowed, one which doesn't make onError or taskComplete promise rejected

Workaround

To prepare a task in such way that there's a way to fail it if it's needed (repro has such way)

Is this a regression?

No or unsure. This never worked, or I haven't tried before.

Affected versions

all

Browser/OS/Node environment

all

@jrencz jrencz changed the title It shouldn't be possible to assign status from outside [task] It shouldn't be possible to assign status from outside Feb 13, 2024
@augustjk
Copy link
Member

That makes sense to me. It would be weird for a user to set the task status themselves. I can't think of a valid reason for that to happen. So making it a getter instead sounds reasonable.

jrencz added a commit to jrencz/lit that referenced this issue Feb 15, 2024
@jrencz jrencz linked a pull request Feb 15, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants