alphapapa / ement.el

A Matrix client for GNU Emacs
GNU General Public License v3.0
508 stars 45 forks source link

ement-api-error "429: You are sending too many requests too quickly..." #96

Closed gcentauri closed 2 years ago

gcentauri commented 2 years ago

This occurs sometimes when I'm typing a message. When it does, I've also experienced Emacs "freezing" or getting stuck in a loop of errors like this and I need to restart. It certainly could be something with my homeserver setup, but possibly ement needs to throttle requests a bit more? I'm going to try to turn off sending typing messages and see if that helps.

Debugger entered--Lisp error: (ement-api-error "429: You are sending too many requests too quickly...")
  signal(ement-api-error ("429: You are sending too many requests too quickly..."))
ement-api-error(#s(plz-error :curl-error nil :response #s(plz-response :version 1.1 :status 429 :headers ((date . "Sat, 10 Sep 2022 15:15:59 GMT") (server . "Apache/2.4.53 (Debian)") (access-control-allow-headers . "Origin, X-Requested-With, Content-Type, Accept, Au...") (access-control-allow-methods . "GET, POST, PUT, DELETE, OPTIONS") (access-control-allow-origin . "*") (content-type . "application/json") (content-length . "108")) :body "{\"errcode\":\"M_LIMIT_EXCEEDED\",\"error\":\"You are sen...") :message nil))
  plz--sentinel(#<process plz-request-curl<21>> "finished\n")
  sit-for(2)
  minibuffer-message(#(" [Ement API error: \"429: You are sending too many ..." 0 73 (read-only t cursor-intangible t face minibuffer-prompt)))
  minibuffer-error-function((ement-api-error "429: You are sending too many requests too quickly...") "" ement-api-error)
  ement-room-read-string("Send message (Emacs): " nil nil nil inherit-input-method)
  byte-code("\10\204\10\0\305\300!\210\11\204\20\0\305\301!\210\10\11\306\307\310\4!\n>\204$\0\311\312\300\6\6D\"\210\3\313H\"\314\216\13\203>\0\f\2036\0..." [ement-room ement-session cl-struct-ement-room-tags ement-room-send-typing ement-room-typing-timer cl--assertion-failed format "Send message (%s): " type-of signal wrong-type-argument 2 #f(compiled-function () #<bytecode 0xb98f4f1be6dd2c>) cancel-timer run-at-time nil 15 ement-room--send-typing ement-room-read-string inherit-input-method :body] 9)
  command-execute(ement-room-send-message)
alphapapa commented 2 years ago

I've never seen that error before. Typing notifications are only sent once every 15 seconds while the minibuffer is open; the spec recommends sending them at least every 20-30 seconds, and it mentions no minimum interval.

I would guess that, if it is related to the typing notifications, it's something to do with your Dendrite setup. Can you reproduce this problem with a matrix.org account?

When it does, I've also experienced Emacs "freezing" or getting stuck in a loop of errors like this and I need to restart.

How do you know it's getting stuck in a loop of repeated errors? It could be caused by Emacs's printing a single backtrace with large data structures, so try this:

(setf print-length 5 print-level 1)

Then if the errors happen again, it shouldn't take so long for Emacs to print them.

Thanks.

alphapapa commented 2 years ago

I think this was fixed by https://github.com/alphapapa/ement.el/commit/f792af5dd9f86c965ad813ea408cebf6d1b83ee9. Thanks for reporting the problem. It wasn't immediately obvious what was causing it, but I discovered it by accident later.

gcentauri commented 2 years ago

hey nice. sorry i never got back around to it. i figured it was probably just something with my VPS web server setup or dendrite.