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: onSelect error capture issue #5229

Closed
wants to merge 2 commits into from

Conversation

gaokun
Copy link
Contributor

@gaokun gaokun commented Feb 8, 2022

First of all, thank you for your contribution! 😄

New feature please send pull request to feature branch, and rest to master branch. Pull request will be merged after one of collaborators approve. Please makes sure that these form are filled before submitting your pull request, thank you!

[中文版模板 / Chinese template]

This is a ...

  • New feature
  • Bug fix
  • Site / document update
  • Component style update
  • TypeScript definition update
  • Refactoring
  • Code style optimization
  • Branch merge
  • Other (about what?)

What's the background?

Please refer to #5204

Test case provided.

error thrown in [onSelect]

image

What's the effect? (Optional if not new feature)

  1. Does this PR affect user? Which part will be affected?
    No
  2. What will say in changelog?
    support promise rejection for event callback
  3. Does this PR contains potential break change or other risk?
    No

Additional Plan? (Optional if not new feature)

This is a demo PR about how to fix #5204 .
It's supposed not to be merged for now.
We need to decide how to do that after code review.

If this PR related with other PR or following info. You can type here.

@gaokun gaokun mentioned this pull request Feb 8, 2022
1 task
@tangjinzhou
Copy link
Member

why not use emit

@gaokun
Copy link
Contributor Author

gaokun commented Feb 10, 2022

As I mentioned in #5204

emit is asynchronous, and wouldn't break main process if error happen.

Example:

function onClick() {
  emit('custom-event', 'reject error');
  console.log('this message will show before onErrorCaptured, and it always show up no matter emit fires error or not');
}

it will be involved in potential risk

@tangjinzhou
Copy link
Member

In this case, the modification cost is too high.

@gaokun
Copy link
Contributor Author

gaokun commented Feb 13, 2022

Yes, it would be.
Select is a complex base component, there are lots of callbacks inside.

Like:

    const onInternalSearchSplit: BaseSelectProps['onSearchSplit'] = words => {
      let patchValues: RawValueType[] = words;

      if (props.mode !== 'tags') {
        patchValues = words
          .map(word => {
            const opt = labelOptions.value.get(word);
            return opt?.value;
          })
          .filter(val => val !== undefined);
      }

      const newRawValues = Array.from(new Set<RawValueType>([...rawValues.value, ...patchValues]));
      triggerChange(newRawValues);
      newRawValues.forEach(newRawValue => {
        triggerSelect(newRawValue, true);    // <=======  callbak in forEach
      });
    };

But I think it is necessary.
It it all about tradeoff, I just put it on the table, and up to you surely.

@github-actions
Copy link

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Stale label Apr 15, 2022
@github-actions github-actions bot closed this Apr 22, 2022
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error Capture Issue
2 participants