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

setErrorHandler won't be called when using on server with startAndBlock #130

Open
rurza opened this issue Apr 25, 2023 · 5 comments
Open

Comments

@rurza
Copy link

rurza commented Apr 25, 2023

It seems that XPCServer's setErrorHandler won't be called, until the connection is closed. I believe it's a bug.

@rurza
Copy link
Author

rurza commented Apr 26, 2023

After some digging it seems that errors I was seeing were mapped to the client errors.

Screenshot 2023-04-26 at 11 40 16

What we're seeing here: BatFi, the app has a timer that sends messages and fails. Then I killed the application, and helper's errorHandler was called.

@jakaplan
Copy link
Contributor

Thanks for the bug report. I will take a look this weekend.

@jakaplan
Copy link
Contributor

Could you provide the actual code or some description of the code involved that's causing this behavior?

Does BatFi contain usage of XPCClient and BatFiHelper have an XPCServer? That's what I'd assume based on typical helper patterns using XPC, but it's surprising to see connectionInvalid as a server side error - it ought to only be possible on the client side.

@jakaplan
Copy link
Contributor

Now that I have access to the source code I tried to replicate this issue, but I'm not sure how to.

I modified RouteHandler.smcStatus(...) to always throw an error and then called the corresponding route from the client and everything worked as expected. However, that's an error generated by the application code whereas what you show in the screenshot is a framework error which I wouldn't expect to occur (because as previously mentioned connectionInvalid ought to only be a client side error).

Could you provide me repro steps and/or a branch of your repository that will automatically replicate this issue upon first run?

@rurza
Copy link
Author

rurza commented May 13, 2023

Hey!
Check out this branch:
https://github.com/rurza/BatFi/tree/SecureXPC-errorHandler

  1. Run the app, and install the helper tool. Run commands "turn off charging" and "turn on charging" commands X times. You should get the SecureXPC.XPCError.insecure error. Great :) Now you can open the Console.app, start streaming messages. You can filter them by software.micropixels.BatFi.Helper. Quit the app.
  2. Jackpot, the helper error handler will be called X times

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

2 participants