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

python-engineio erroneously ignores ValueError exceptions from applications #44

Closed
lericson opened this issue Apr 5, 2017 · 8 comments
Assignees
Labels

Comments

@lericson
Copy link

lericson commented Apr 5, 2017

People generally want to know when their code crashes. However, https://github.com/miguelgrinberg/python-engineio/blob/master/engineio/asyncio_socket.py#L182 explicitly ignores ValueErrors. There is no rationale, there is no explanation. Please remove this ASAP.

@miguelgrinberg
Copy link
Owner

People generally want to know when their code crashes

I think you need to read up on Exceptions more. Crashes raise exceptions, that's true, but exceptions are also used as a signaling mechanism, which is the case in this snippet of code you are indicated, which receives a signal from https://github.com/miguelgrinberg/python-engineio/blob/master/engineio/asyncio_socket.py#L47.

@lericson
Copy link
Author

lericson commented Apr 5, 2017

Oh. I see. Interesting. Insulting your users by insinuating they don't know how Python. I know what exceptions are. I've used Python for a decade. This one is called Value Error, and as the name suggests, is meant to signal one thing: errors.

Co-opting Python's most common exception type to mean "unhandled WebSocket packet type" seems ill-conceived, especially considering the user very likely wants to know when packets are being dropped. All in all, a pretty bad way to deal with the problem.

More so, if your user's code errors with that exception type, which is raised by basically every single library both standard and PyPI, your library simply silences it -- because it might mean the last WebSocket packet's type isn't recognized by the library.

I urge you to rethink this design.

@miguelgrinberg
Copy link
Owner

miguelgrinberg commented Apr 5, 2017

I did not mean to insult you. You suggested I was suppressing ValueError crashes from the application, I'm telling you this specific instance of ValueError is not an application crash.

Have you found a situation in which a ValueError raised in any other part of the code, including your own application is caught in the place you indicated? If you did, then please report the specific error you have found and I'll consider it a bug to be fixed.

@lericson
Copy link
Author

lericson commented Apr 5, 2017

Sure, just raise a ValueError from a @sio.on("foo") handler with python-socketio.

@lericson
Copy link
Author

lericson commented Apr 5, 2017

I'm using aiohttp, I can construct a minimal case if you would like me to. I doubt it's necessary though.

@lericson
Copy link
Author

lericson commented Apr 5, 2017

Again though, I'm not familiar enough with the internals of the code to know, but silencing unrecognized packet types seems like trouble down the line. I think emitting a warning log message for unrecognized packet types seems more fitting.

@miguelgrinberg
Copy link
Owner

miguelgrinberg commented Apr 5, 2017

Oh, now I see what you mean, I was missing the context to understand what you meant.

@miguelgrinberg miguelgrinberg reopened this Apr 5, 2017
@miguelgrinberg miguelgrinberg self-assigned this Apr 5, 2017
@miguelgrinberg miguelgrinberg added bug and removed invalid labels Apr 5, 2017
@lericson
Copy link
Author

lericson commented Apr 5, 2017

I'm sorry, I was perhaps not very clear. 😄 Happy we're on the same page.

lericson added a commit to lericson/python-engineio that referenced this issue Apr 5, 2017
miguelgrinberg added a commit that referenced this issue Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants