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: don't error when calling #sendHaves without a peer #691

Merged

Conversation

EvanHahn
Copy link
Contributor

We were effectively doing something like this:

if (!object) {
  console.warn('no object', object.propertyAccessThatWillFail)
}

This could throw an error because we can't access properties on null or undefined.1

This updates the log message to avoid this error.

Footnotes

  1. It's possible that the value was another falsy value, such as false, where you can technically access properties. I still think this change is an improvement in that situation, because false.remotePublicKey is undefined, which isn't very useful.

We were effectively doing something like this:

```javascript
if (!object) {
  console.warn('no object', object.propertyAccessThatWillFail)
}
```

This could throw an error because we can't access properties on `null`
or `undefined`.[^0]

This updates the log message to avoid this error.

[^0]: It's possible that the value was another falsy value, such as
`false`, where you can technically access properties. I still think this
change is an improvement in that situation, because
`false.remotePublicKey` is `undefined`, which isn't very useful.
@EvanHahn EvanHahn merged commit 002b981 into main May 29, 2024
7 checks passed
@EvanHahn EvanHahn deleted the improve-error-handling-when-calling-sendhaves-without-peer branch May 29, 2024 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant