Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

/_matrix/key/v2/query: 'NoneType' object has no attribute 'registerProducer' #6700

Closed
anoadragon453 opened this issue Jan 14, 2020 · 5 comments · Fixed by #8465
Closed

/_matrix/key/v2/query: 'NoneType' object has no attribute 'registerProducer' #6700

anoadragon453 opened this issue Jan 14, 2020 · 5 comments · Fixed by #8465
Labels
z-bug (Deprecated Label) z-p2 (Deprecated Label)

Comments

@anoadragon453
Copy link
Member

Description

A traceback I saw while skimming my logs:

2020-01-14 15:02:13,505 - synapse.http.server - 109 - ERROR - POST-48708- Failed handle request via 'RemoteKey': <XForwardedForRequest at 0x7f0fa40a9f60 method='POST' uri='/_matrix/key/v2/query' clientproto='HTTP/1.1' site=8008>
  File "/home/synapse/synapse/env/lib/python3.7/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
    result = g.send(result)
StopIteration: {('mtrx.pro-i-l.de', 'ed25519:a_lehF', None): [{'key_id': 'ed25519:a_lehF', 'from_server': 'matrix.org', 'ts_added_ms': 1576922916596, 'ts_valid_until_ms': 1576921056903, 'key_json': <memory at 0x7f1111544108>}, {'key_id': 'ed25519:a_lehF', 'from_serve

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/synapse/synapse/env/lib/python3.7/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
    result = g.send(result)
StopIteration: {('mtrx.pro-i-l.de', 'ed25519:a_lehF', None): [{'key_id': 'ed25519:a_lehF', 'from_server': 'matrix.org', 'ts_added_ms': 1576922916596, 'ts_valid_until_ms': 1576921056903, 'key_json': <memory at 0x7f1111544108>}, {'key_id': 'ed25519:a_lehF', 'from_serve

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/synapse/synapse/env/lib/python3.7/site-packages/synapse/http/server.py", line 77, in wrapped_request_handler
    await h(self, request)
  File "/home/synapse/synapse/env/lib/python3.7/site-packages/synapse/rest/key/v2/remote_key_resource.py", line 125, in _async_render_POST
    await self.query_keys(request, query, query_remote_on_cache_miss=True)
  File "/home/synapse/synapse/env/lib/python3.7/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
    result = g.send(result)
  File "/home/synapse/synapse/env/lib/python3.7/site-packages/synapse/rest/key/v2/remote_key_resource.py", line 230, in query_keys
    respond_with_json_bytes(request, 200, encode_canonical_json(results))
  File "/home/synapse/synapse/env/lib/python3.7/site-packages/synapse/http/server.py", line 507, in respond_with_json_bytes
    producer.start()
  File "/home/synapse/synapse/env/lib/python3.7/site-packages/twisted/web/static.py", line 765, in start
    self.request.registerProducer(self, False)
  File "/home/synapse/synapse/env/lib/python3.7/site-packages/twisted/web/http.py", line 986, in registerProducer
    self.channel.registerProducer(producer, streaming)
AttributeError: 'NoneType' object has no attribute 'registerProducer'

Not sure if this is a bug or a fluke with a broken connection.

Version information

Synapse v1.8.0 via pip

@richvdh
Copy link
Member

richvdh commented Jan 15, 2020

I think this is a dup of #5304

@richvdh richvdh closed this as completed Jan 15, 2020
@richvdh
Copy link
Member

richvdh commented Jan 15, 2020

ok, it's not quite, but it's closely related

@richvdh
Copy link
Member

richvdh commented Jan 15, 2020

I've explained what I think is going on here at #5304 (comment), but am going to leave this open too to track the fact that it probably needs fixing in both places.

The trivial fix here is to add if request._disconnected: return to respond_with_json_bytes.

(the error is harmless except for the noise in the log, and that the other end has timed out)

@richvdh
Copy link
Member

richvdh commented Jan 15, 2020

also, the fact that you're seeing this error means that someone is using your server as a key notary, which is an interesting choice.

@anoadragon453
Copy link
Member Author

also, the fact that you're seeing this error means that someone is using your server as a key notary, which is an interesting choice.

Indeed...

@neilisfragile neilisfragile added z-p2 (Deprecated Label) z-bug (Deprecated Label) labels Jan 22, 2020
anoadragon453 added a commit that referenced this issue Oct 6, 2020
…cted (#8465)

This PR ports the quick fix from #2796 to further methods which handle media, URL preview and `/key/v2/server` requests. This prevents a harmless `ERROR` that comes up in the logs when we were unable to respond to a client request when the client had already disconnected. In this case we simply bail out if the client has already done so.

This is the 'simple fix' as suggested by #5304 (comment).

Fixes #6700
Fixes #5304
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
z-bug (Deprecated Label) z-p2 (Deprecated Label)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants