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

smoothCornersScript throws error when called twice #2002

Closed
1 of 3 tasks
yangwooseong opened this issue Feb 19, 2024 · 0 comments · Fixed by #2010
Closed
1 of 3 tasks

smoothCornersScript throws error when called twice #2002

yangwooseong opened this issue Feb 19, 2024 · 0 comments · Fixed by #2010
Labels
bug Issues related to anything that isn't working good first issue Issue that good for newcomers

Comments

@yangwooseong
Copy link
Collaborator

Summary

smoothCornersScript throws error when called twice.

Reproduction process

smoothcorners를 사용하는 BezierProvider 를 2번 이상 호출하는 경우, 사용처에서 Uncaught DOMException: Failed to execute 'registerPaint' on 'PaintWorkletGlobalScope': A class with name:'smooth-corners' is already registered. 에러가 뜨게 됩니다. try catch 로 묶어서 error 가 뜨지않도록 하면 좋겠습니다.

image

Version of bezier-react

1.20.0

Browser

No response

Operating system

  • macOS
  • Windows
  • Linux

Additonal Information

No response

@yangwooseong yangwooseong added bug Issues related to anything that isn't working good first issue Issue that good for newcomers labels Feb 19, 2024
sungik-choi pushed a commit that referenced this issue Feb 21, 2024
… twice (#2010)

<!--
  How to write a good PR title:
- Follow [the Conventional Commits
specification](https://www.conventionalcommits.org/en/v1.0.0/).
  - Give as much context as necessary and as little as possible
  - Prefix it with [WIP] while it’s a work in progress
-->

## Self Checklist

- [x] I wrote a PR title in **English** and added an appropriate
**label** to the PR.
- [x] I wrote the commit message in **English** and to follow [**the
Conventional Commits
specification**](https://www.conventionalcommits.org/en/v1.0.0/).
- [x] I [added the
**changeset**](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md)
about the changes that needed to be released. (or didn't have to)
- [x] I wrote or updated **documentation** related to the changes. (or
didn't have to)
- [x] I wrote or updated **tests** related to the changes. (or didn't
have to)
- [x] I tested the changes in various browsers. (or didn't have to)
  - Windows: Chrome, Edge, (Optional) Firefox
  - macOS: Chrome, Edge, Safari, (Optional) Firefox

## Related Issue
<!-- Please link to issue if one exists -->
- fixes #2002 
<!-- Fixes #0000 -->

## Summary
<!-- Please brief explanation of the changes made -->
Add `try catch` block to mute the error when `smoothCornerScript` is
called twice.

## Details
<!-- Please elaborate description of the changes -->
According to the [MDN documentation on
`registerPaint()`](https://developer.mozilla.org/en-US/docs/Web/API/PaintWorkletGlobalScope/registerPaint#exceptions),
this function only throws two errors. One when the parameters aren't
met, throwing `TypeError` and the other when a worklet already exists
with the given name, throwing `DOMException`. I thought that any of
those two case won't happen in this particular case, so I just no-oped
the `catch` statement. If it is not a good approach, I can narrow the
error down to the later one, `DOMException`.

### Breaking change? (Yes/No)
<!-- If Yes, please describe the impact and migration path for users -->
No.

## References
<!-- Please list any other resources or points the reviewer should be
aware of -->


https://developer.mozilla.org/en-US/docs/Web/API/PaintWorkletGlobalScope/registerPaint#exceptions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues related to anything that isn't working good first issue Issue that good for newcomers
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant