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: cannot set property name of which has only a getter #5574

Merged
merged 1 commit into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wet-hornets-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"pnpm": patch
---

Don't fail if cannot override the name field of the error object [#5572](https://github.com/pnpm/pnpm/issues/5572).
6 changes: 5 additions & 1 deletion packages/pnpm/src/err.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ export function errorHandler (error: Error) {
return
}
if (error.name != null && error.name !== 'pnpm' && !error.name.startsWith('pnpm:')) {
error.name = 'pnpm'
try {
error.name = 'pnpm'
} catch {
// Sometimes the name property is read-only
}
Copy link
Member

Choose a reason for hiding this comment

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

I think this change can also be merged to v6 branch since there has a similar issue: #4270

Copy link
Member Author

Choose a reason for hiding this comment

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

oh, wow

}

// bole passes only the name, message and stack of an error
Expand Down