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

Backend(LN): catch NOnionException TorOperations #185

Merged
merged 2 commits into from
Nov 16, 2022

Conversation

parhamsaremi
Copy link
Contributor

Catch the NOnionException after the Retries have finished and the problem still exists. We catch the exception and return an error.

Fixes #181
Fixes #182

@knocte
Copy link
Member

knocte commented Nov 9, 2022

@aarani please review

@knocte
Copy link
Member

knocte commented Nov 10, 2022

Fixes #181

Are you sure? I think this is false ^

@knocte
Copy link
Member

knocte commented Nov 10, 2022

@aarani please review

ping

@aarani
Copy link
Contributor

aarani commented Nov 10, 2022

LGTM

@knocte
Copy link
Member

knocte commented Nov 10, 2022

LGTM

Are you sure? Why are we replacing specific exception types with generic exception types in this PR? I don't understand.

@parhamsaremi
Copy link
Contributor Author

Fixes #181

Are you sure? I think this is false ^

Actually, I think this PR with the PR that I made to NOnion would solve this problem. In that PR, I converted the System.Exception to IOException and this one catches the NOntion Exceptions.

@parhamsaremi
Copy link
Contributor Author

LGTM

Are you sure? Why are we replacing specific exception types with generic exception types in this PR? I don't understand.

When we catch NOnionExceptions in TorOperations, we have to return them as Result<> type. Since the code in those files was operating with SocketException, I had to change the types to a more generic one, so that I could be able to return both of these errors 🤔

@knocte
Copy link
Member

knocte commented Nov 11, 2022

Actually, I think this PR with the PR that I made to NOnion would solve this problem. In that PR, I converted the System.Exception to IOException and this one catches the NOntion Exceptions.

So?

@knocte
Copy link
Member

knocte commented Nov 11, 2022

Since the code in those files was operating with SocketException

I don't understand the reasoning here. The NOnion PR that was recently merged was done so that we didn't need to catch generic exceptions. And this PR introduces generic exceptions?

@parhamsaremi
Copy link
Contributor Author

Actually, I think this PR with the PR that I made to NOnion would solve this problem. In that PR, I converted the System.Exception to IOException and this one catches the NOntion Exceptions.

So?

Should I link that PR too in the description? I didn't know where I should put the link! should I put it in the body? or in the footer?

@parhamsaremi
Copy link
Contributor Author

parhamsaremi commented Nov 11, 2022

Since the code in those files was operating with SocketException

I don't understand the reasoning here. The NOnion PR that was recently merged was done so that we didn't need to catch generic exceptions. And this PR introduces generic exceptions?

We don't catch generic exceptions 🤔 we are just catching NOnionException but the type of that should have changed so that We could pass both NOnionException and SocketException to the upper level functions. If an System.Excption is thrown from the NOninon, we are not catching it.

@knocte
Copy link
Member

knocte commented Nov 11, 2022

We don't catch generic exceptions 🤔 we are just catching NOnionException but the type of that should have changed so that We could pass both NOnionException and SocketException to the upper level functions. If an System.Excption is thrown from the NOninon, we are not catching it.

If you need a type to represent Exception A or Exception B, make a new DU. Do not use base class System.Exception, ever. It invites bad practices.

@knocte
Copy link
Member

knocte commented Nov 11, 2022

Should I link that PR too in the description? I didn't know where I should put the link! should I put it in the body? or in the footer?

Why would you want to link that PR in the description?

@parhamsaremi
Copy link
Contributor Author

We don't catch generic exceptions thinking we are just catching NOnionException but the type of that should have changed so that We could pass both NOnionException and SocketException to the upper level functions. If an System.Excption is thrown from the NOninon, we are not catching it.

If you need a type to represent Exception A or Exception B, make a new DU. Do not use base class System.Exception, ever. It invites bad practices.

Hmmm sounds good, I'll work on it 🤔

@knocte
Copy link
Member

knocte commented Nov 11, 2022

Hmmm sounds good, I'll work on it

Actually, are we sure we want to hardcode SocketException in geewallet? Shouldn't NOnion wrap that so that we don't have to?

@parhamsaremi
Copy link
Contributor Author

Should I link that PR too in the description? I didn't know where I should put the link! should I put it in the body? or in the footer?

Why would you want to link that PR in the description?

My understanding was that these two PRs are connected and both of them Fix the issue with each other 🤔

@parhamsaremi
Copy link
Contributor Author

Hmmm sounds good, I'll work on it

Actually, are we sure we want to hardcode SocketException in geewallet? Shouldn't NOnion wrap that so that we don't have to?

I'm not familiar with SocketExceptions, but I think this idea sounds cleaner 🤔

@knocte
Copy link
Member

knocte commented Nov 11, 2022

My understanding was that these two PRs are connected and both of them Fix the issue with each other

That PR is already merged. If we merge this PR, the bug is still not fixed. You're still missing one important thing.

@knocte
Copy link
Member

knocte commented Nov 11, 2022

I'm not familiar with SocketExceptions, but I think this idea sounds cleaner

Then try it. (I'm not familiar with them either, I just receive them sometimes and I need to make my code protected against them. I've never looked into their source code.)

@parhamsaremi
Copy link
Contributor Author

My understanding was that these two PRs are connected and both of them Fix the issue with each other

That PR is already merged. If we merge this PR, the bug is still not fixed. You're still missing one important thing.

right 👍

@parhamsaremi
Copy link
Contributor Author

My understanding was that these two PRs are connected and both of them Fix the issue with each other

That PR is already merged. If we merge this PR, the bug is still not fixed. You're still missing one important thing.

I'll work on updating the NOnion version.

@parhamsaremi
Copy link
Contributor Author

Hmmm sounds good, I'll work on it

Actually, are we sure we want to hardcode SocketException in geewallet? Shouldn't NOnion wrap that so that we don't have to?

For now, I updated the code such that we won't have the problem of generic Exception by defining the case for NOnionException. I think the SocketException needs more investigation.

@knocte
Copy link
Member

knocte commented Nov 15, 2022

The CI of commit titled Backend,Tests: update NOnion version is red because it doesn't even build. It doesn't make sense to separate it from the next commit which fixes the build.

@parhamsaremi
Copy link
Contributor Author

The CI of commit titled Backend,Tests: update NOnion version is red because it doesn't even build. It doesn't make sense to separate it from the next commit which fixes the build.

Sure I'll squash them right now.

@parhamsaremi parhamsaremi force-pushed the issue-181-squashed branch 3 times, most recently from 9a8f95e to 393d60e Compare November 15, 2022 09:34
@knocte
Copy link
Member

knocte commented Nov 15, 2022

When merging the last 2 commits, you discarded the message where you explained the use of new keyword, why???

@knocte
Copy link
Member

knocte commented Nov 15, 2022

Screenshot 2022-11-15 at 7 19 44 PM

^ Both commits fix bug 181?

@parhamsaremi
Copy link
Contributor Author

Screenshot 2022-11-15 at 7 19 44 PM

^ Both commits fix bug 181?

My bad. Technically both of them are needed. But I should have only mentioned it in the second one.

@parhamsaremi
Copy link
Contributor Author

When merging the last 2 commits, you discarded the message where you explained the use of new keyword, why???

oops I'll fix this right away.

@knocte
Copy link
Member

knocte commented Nov 15, 2022

When merging the last 2 commits, you discarded the message where you explained the use of new keyword, why???

You didn't read this?

Catch the NOnionException after Retrys have finished and the
problem still exists. We catch the exception and return an
error.

Fixes nblockchain#182
@parhamsaremi
Copy link
Contributor Author

When merging the last 2 commits, you discarded the message where you explained the use of new keyword, why???

I answered it and said it was my bad. I'm adding it right now. if you are fixating on the why, I'm not sure I think I might have just missed it when I was squashing two commits.

@parhamsaremi parhamsaremi force-pushed the issue-181-squashed branch 3 times, most recently from b3d1a72 to 891c0cd Compare November 15, 2022 12:32
We have to use new for instanciating TorServiceHost since in
the new version of NOnion this type is IDisposable.

Fixes nblockchain#181
Fixes nblockchain#184
Fixes nblockchain#186
@parhamsaremi parhamsaremi force-pushed the issue-181-squashed branch 2 times, most recently from 8308f87 to 5e0d4ba Compare November 15, 2022 12:33
@knocte
Copy link
Member

knocte commented Nov 15, 2022

I answered it and said it was my bad. I'm adding it right now. if you are fixating on the why, I'm not sure I think I might have just missed it when I was squashing two commits.

Sorry it's just that I saw you addressing only 1 of my comments and pushing without addressing my 2nd comment. CI in lightning branch takes long, so if you're gonna push, adress all comments first without pushing in between, otherwise you clog GitHubActions with useless (obsolete) jobs that make the PR's CI take unnecessary longer.

@knocte knocte merged commit 96970fe into nblockchain:lightning Nov 16, 2022
This pull request was closed.
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.

3 participants