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

Handling socket errors in recursive functions #214

Closed
rodolfomiranda opened this issue Mar 20, 2024 · 1 comment
Closed

Handling socket errors in recursive functions #214

rodolfomiranda opened this issue Mar 20, 2024 · 1 comment

Comments

@rodolfomiranda
Copy link
Contributor

I was dealing with a problem when creating an AID where one of AID is down when collecting receipts. That situation may cause a socket error in a call to socket.getaddrinfo form hio, raising an error.
The error code is dependent on the operating system, it can be caused for several reasons for example a problem in domain name resolution.

That error is propagated back to keripy and keria where the exception is not being handled.

In my case, keria crashed in line 442 of the following function that treats receipts with witnesses.

def recur(self, tyme=None):
while True:
if self.witners:
msg = self.witners.popleft()
serder = msg["serder"]
# If we are a rotation event, may need to catch new witnesses up to current key state
if serder.ked['t'] in (Ilks.rot, Ilks.drt):
adds = serder.ked["ba"]
for wit in adds:
yield from self.receiptor.catchup(serder.pre, wit)
yield from self.receiptor.receipt(serder.pre, serder.sn)
yield self.tock

Note that it's a recursive function that can make the keria process to crash as a whole.
I can create a PR to handle the exception there and safeguard the process by doing nothing but logging the error. I want to receive feedback for that approach. Other option may be to handle on the receiptor function in keripy

https://github.com/WebOfTrust/keripy/blob/543057e2d30712477b114f64c158dbf1564149fa/src/keri/app/agenting.py#L40

@rodolfomiranda
Copy link
Contributor Author

Fixed in keripy PR #273

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

No branches or pull requests

1 participant