pranavgupta1234 / rqmonitor

Flask based more dynamic and actionable frontend dashboard for monitoring Redis Queue 👩🏿‍💻 http://python-rq.org
Apache License 2.0
186 stars 24 forks source link

Ajax error in Jobs tab #2

Closed Angi2412 closed 4 years ago

Angi2412 commented 4 years ago

Hello, first: thank you for implementing this new monitor as an alternative for the RQ-dashboard :)

second: I deployed the monitor via docker-compose and when I wanted to open the "Jobs" tab in the left-hand menu I get a pop up that says: "DataTables warning: table id=jobs_table - Ajax error.[...]" - I attached the screenshot.

Screenshot (26)

pranavgupta1234 commented 4 years ago

Hello @Angi2412

Is the error only coming up for jobs, or for queues and workers as well ? is there some error thrown on flask server ?
As per the error reference https://datatables.net/manual/tech-notes/7 , the server is responding with some error code and is currently not handled in jobs datatable. Thanks for pointing it out, I will add error handling for this in next release.

For now it would be helpful if you can follow through the debugging steps mentioned in the above link and check what error code is server responding with or if some error is thrown on Flask server.

Angi2412 commented 4 years ago

Hello @pranavgupta1234 The error only occurs when selecting the "Jobs" tab, not on the others. Here is a screenshot from the log:

Screenshot (27)

And here is the log from the flask server: Seems like there is some kind of problem with the format of the date?


RQ Monitor version 0.0.7
08:08:57:  * Running on 0.0.0.0:8899
 * Serving Flask app "rqmonitor.cli" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
08:10:15: Exception on /jobs [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/rq/utils.py", line 169, in utcparse
    return datetime.datetime.strptime(string, _TIMESTAMP_FORMAT)
  File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
    (data_string, format))
ValueError: time data '' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/rqmonitor/decorators.py", line 7, in _wrapper
    _rendered_template = func(*args, **kwargs)
  File "/rqmonitor/bp.py", line 213, in list_jobs_api
    jobs = resolve_jobs(job_counts, start, length)
  File "/rqmonitor/utils.py", line 445, in resolve_jobs
    cursor+length)
  File "/rqmonitor/utils.py", line 228, in list_jobs_in_queue_registry
    return [Job.fetch(job_id) for job_id in job_ids]
  File "/rqmonitor/utils.py", line 228, in <listcomp>
    return [Job.fetch(job_id) for job_id in job_ids]
  File "/usr/local/lib/python3.7/site-packages/rq/job.py", line 299, in fetch
    job.refresh()
  File "/usr/local/lib/python3.7/site-packages/rq/job.py", line 506, in refresh
    self.restore(data)
  File "/usr/local/lib/python3.7/site-packages/rq/job.py", line 475, in restore
    self.ended_at = str_to_date(obj.get('ended_at'))
  File "/usr/local/lib/python3.7/site-packages/rq/utils.py", line 256, in str_to_date
    return utcparse(as_text(date_str))
  File "/usr/local/lib/python3.7/site-packages/rq/utils.py", line 172, in utcparse
    return datetime.datetime.strptime(string, '%Y-%m-%dT%H:%M:%SZ')
  File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
    (data_string, format))
ValueError: time data '' does not match format '%Y-%m-%dT%H:%M:%SZ'
Angi2412 commented 4 years ago

@pranavgupta1234 Maybe it has something to do with the fact that currently there are no jobs in the database and therefore no time data?

pranavgupta1234 commented 4 years ago

@Angi2412 , thank you so much for the detailed description. I think we have caught the real culprit here. I will add a fix for this soon. Anyways the ajax error also needed a proper handling.

pranavgupta1234 commented 4 years ago

Hi @Angi2412 , The above bug is fixed in v0.0.8 release. Error handling is also improved. You will see any such errors on dashboard itself now. error

In case if issue persists, feel free to reopen the issue.