-
Notifications
You must be signed in to change notification settings - Fork 5
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
Implementation flaw of the middleware prevents concurrent requests #27
Comments
Hi @hongyuan1306, just seeing this now as I come back around to this repo. I think your analysis is correct. Middleware state should be avoided! An alternative to storing inside |
Hi @hongyuan1306, @florimondmanca,
|
I think the current vesion of the msgpack middleware has a serious implementaion flaw that will cause errors when parallel requests are processed.
During each request, some request scoped variables, like
receive
,send
,should_decode_from_msgpack_to_json
,initial_message
etc, are stored on the middleware instance itself:The problem is that there is only one instance of the middleware, but multiple parallel requests are normally in progress, so these variables will get mixed up between the requests. When for example
receive_with_msgpack
is called to process a request,self.receive
could already have been overwritten by a subsequent request.The proper way to pass request scoped values between the various instance methods would be to use request or function scoped storage, like
scope
, wrapped function or partial function.The text was updated successfully, but these errors were encountered: