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

chore: fix repeated error message #8153

Merged
merged 1 commit into from
May 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -831,10 +831,10 @@ export function resolvePackageEntry(
return resolvedEntryPoint
}
}
packageEntryFailure(id)
} catch (e) {
packageEntryFailure(id, e.message)
}
packageEntryFailure(id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this work? When there is an exception, won't packageEntryFailure be called twice after this change? And if there isn't an exception, isn't it the same to place the function at the end of the try block or after it 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

packageEntryFailure is essentially a throw new Error().

So the previous behavior is:

  • case (a): no package entry is found
    1. packageEntryFailure(id) is called in L834
    2. an error is thrown inside that
    3. that error is caught by catch in L835
    4. packageEntryFailure(id, e) is called in L836
    5. an error is thrown inside that and gets out of this function
  • case (b): error happened while resolving package entry
    1. error happens inside the try block
    2. that error is caught by catch in L835
    3. packageEntryFailure(id, e) is called in L836
    4. an error is thrown inside that and gets out of this function

the PR behavior is:

  • case (a): no package entry is found
    1. packageEntryFailure(id) is called in L837
    2. an error is thrown inside that and gets out of this function
  • case (b): error happened while resolving package entry
    • this is the same with the current behavior

Copy link
Member

@patak-dev patak-dev May 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation! I overlooked the throw error as a log only inside that function. Edit: I overlook the throw twice 😅, double thanks!

}

function packageEntryFailure(id: string, details?: string) {
Expand Down