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

Prevent crash on pagination. #4263

Merged
merged 1 commit into from
Feb 21, 2019
Merged

Prevent crash on pagination. #4263

merged 1 commit into from
Feb 21, 2019

Conversation

rkfg
Copy link
Contributor

@rkfg rkfg commented Dec 5, 2018

Today I've got pagination stuck on scrolling back and this was in the log:

2018-12-05 09:22:58,198 - synapse.http.server - 112 - ERROR - GET-8313- Failed handle request
via <function _async_render at 0x7f7d18ff8de8>: <SynapseRequest at 0x7f7ccb48d680
method=u'GET' uri=u'/_matrix/client/r0/rooms/<...>/messages?from=t361589-2272987_8803529_88_1180453_319160_392_21245_28472_14&
limit=20&dir=b&filter=%7B%22lazy_load_members%22%3Atrue%7D' clientproto=u'HTTP/1.0' site=8009>: Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 654, in _runCallbacks
    current.result = callback(current.result, *args, **kw)
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1475, in gotResult
    _inlineCallbacks(r, g, status)
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/usr/lib/python2.7/dist-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
--- <exception caught here> ---
  File "/usr/lib/python2.7/dist-packages/synapse/http/server.py", line 81, in wrapped_request_handler
    yield h(self, request)
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/usr/lib/python2.7/dist-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "/usr/lib/python2.7/dist-packages/synapse/http/server.py", line 316, in _async_render
    callback_return = yield callback(request, **kwargs)
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/usr/lib/python2.7/dist-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "/usr/lib/python2.7/dist-packages/synapse/rest/client/v1/room.py", line 479, in on_GET
    event_filter=event_filter,
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
    result = g.send(result)
  File "/usr/lib/python2.7/dist-packages/synapse/handlers/pagination.py", line 266, in get_messages
    events[0].event_id, state_filter=state_filter,
exceptions.IndexError: list index out of range

So I added a check if events actually has something and then pagination worked again. No idea why it broke, I have some ignored users so maybe that's why.

@codecov-io
Copy link

codecov-io commented Dec 6, 2018

Codecov Report

Merging #4263 into develop will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4263      +/-   ##
===========================================
- Coverage    73.63%   73.62%   -0.01%     
===========================================
  Files          298      298              
  Lines        29776    29776              
  Branches      4875     4875              
===========================================
- Hits         21925    21923       -2     
- Misses        6419     6420       +1     
- Partials      1432     1433       +1
Impacted Files Coverage Δ
synapse/handlers/pagination.py 91.66% <100%> (ø) ⬆️
synapse/state/v1.py 90.69% <0%> (-1.56%) ⬇️
synapse/state/v2.py 93.29% <0%> (-0.52%) ⬇️
synapse/handlers/user_directory.py 71.03% <0%> (+0.3%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b0c24a6...ae19a7d. Read the comment docs.

@erikjohnston
Copy link
Member

Thanks! Sorry for taking so long to look at it.

@erikjohnston erikjohnston merged commit b9d6756 into matrix-org:develop Feb 21, 2019
@@ -0,0 +1 @@
Prevent crash on pagination.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erikjohnston please can we not use the word "crash" when we mean "throw an exception". "crash" sounds like the whole process dies.

@rkfg rkfg deleted the develop branch February 27, 2019 10:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants