Skip to content

Updates for recent Hubot #34

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

xurizaemon
Copy link
Collaborator

@xurizaemon xurizaemon commented Apr 29, 2025

Testing ESM update for recent Hubot

@davidar I see that this adapter has been unmaintained a while. If I can get this working with current Hubot, should we move it over to the @hubot-friends/ group where some other adapters live?

I'm happy to run it from a fork as well, no need for you to do anything at all 😄

Progress report / tasks

WIP, looks promising. I am building on existing work from other hubot-matrix forks, all credit to the contributors below.

  • Adapter can connect to Matrix.org server!
  • Adapter is NPM compatible with current release of Hubot! (v11)
  • A Hubot instance can connect to Matrix
  • Hubot can set its name in Matrix
  • Hubot does not immediately get 429 banned by Matrix.org for requesting too many sync updates at once
  • Hubot can send messages to a Matrix room
  • Hubot can see messages in a Matrix room

@xurizaemon xurizaemon force-pushed the update-esm branch 2 times, most recently from 2216fa4 to 580a780 Compare April 29, 2025 22:44
@xurizaemon xurizaemon marked this pull request as draft April 30, 2025 00:28
@xurizaemon
Copy link
Collaborator Author

xurizaemon commented Apr 30, 2025

Currently, the bot seems to log in and sync, but fails to read from or write to the room.

I had to disable presence feature entirely to get past being 429'd by matrix.org for too many updates.

Will exit after 120000 ms, messaging !xRoABCDEFGHIJKLMNO:example.org

This message above is expected, it's hubot-farewell doing as configured, so that a CI job can test posting to the room then exit. The bot should post two messages: one after it connects (hubot-startup), and one just before it exits (hubot-farewell). Neither appear.

Here's the output of a test run:

$ npm start
> [email protected] start
> hubot
{"level":50,"time":1745974349697,"pid":182,"hostname":"runner--azerasq-project-69387289-concurrent-0","name":"CI job #9873283596 for exampleorg/examplebot","msg":"Path /builds/exampleorg/examplebot/configuration does not exist"}
{"level":30,"time":1745974350200,"pid":182,"hostname":"runner--azerasq-project-69387289-concurrent-0","name":"CI job #9873283596 for exampleorg/examplebot","msg":"Constructor"}
{"level":30,"time":1745974350287,"pid":182,"hostname":"runner--azerasq-project-69387289-concurrent-0","name":"CI job #9873283596 for exampleorg/examplebot","msg":"Run CI job #9873283596 for exampleorg/examplebot"}
FetchHttpApi: --> POST https://matrix-client.matrix.org/_matrix/client/v3/login
{"level":30,"time":1745974350287,"pid":182,"hostname":"runner--azerasq-project-69387289-concurrent-0","name":"CI job #9873283596 for exampleorg/examplebot","msg":"Creating a new session: no authentication token can be found in local storage."}
FetchHttpApi: <-- POST https://matrix-client.matrix.org/_matrix/client/v3/login [696ms 200]
{"level":30,"time":1745974350990,"pid":182,"hostname":"runner--azerasq-project-69387289-concurrent-0","name":"CI job #9873283596 for exampleorg/examplebot","msg":"Logged in [MASKED] on device UXYZXYZXYZ"}
Getting saved sync token...
Getting push rules...
Attempting to send queued to-device messages
Got saved sync token
Got reply from saved sync, exists? false
All queued to-device messages sent
Adding default global override push rule .org.matrix.msc3786.rule.room.server_acl
Adding default global underride push rule .org.matrix.msc3914.rule.room.call
Got push rules
Prepare lazy loading for sync...
Storing client options...
Stored client options
Getting filter...
Fetched new server capabilities
Sending initial sync request...
Waiting for saved sync before starting sync processing...
Adding default global override push rule .org.matrix.msc3786.rule.room.server_acl
Adding default global underride push rule .org.matrix.msc3914.rule.room.call
{"level":30,"time":1745974351857,"pid":182,"hostname":"runner--azerasq-project-69387289-concurrent-0","name":"CI job #9873283596 for exampleorg/examplebot","msg":"Synced 2 rooms"}
Resuming queue after resumed sync
Attempting to send queued to-device messages
All queued to-device messages sent
{"level":30,"time":1745974351857,"pid":182,"hostname":"runner--azerasq-project-69387289-concurrent-0","name":"CI job #9873283596 for exampleorg/examplebot","msg":"Setting display name to CI job #9873283596 for exampleorg/examplebot"}
{"level":50,"time":1745974351862,"pid":182,"hostname":"runner--azerasq-project-69387289-concurrent-0","name":"CI job #9873283596 for exampleorg/examplebot","msg":"Path /builds/exampleorg/examplebot/scripts does not exist"}
{"level":50,"time":1745974351862,"pid":182,"hostname":"runner--azerasq-project-69387289-concurrent-0","name":"CI job #9873283596 for exampleorg/examplebot","msg":"Path /builds/exampleorg/examplebot/src/scripts does not exist"}
Will exit after 120000 ms.
{"level":30,"time":1745974351864,"pid":182,"hostname":"runner--azerasq-project-69387289-concurrent-0","name":"CI job #9873283596 for exampleorg/examplebot","msg":"Will exit after 120000 ms, messaging !xRoABCDEFGHIJKLMNO:example.org."}
{"level":30,"time":1745974351865,"pid":182,"hostname":"runner--azerasq-project-69387289-concurrent-0","name":"CI job #9873283596 for exampleorg/examplebot","msg":"Sending to !xRoABCDEFGHIJKLMNO:example.org: Hello from Gitlab CI!\nThis job is https://gitlab.com/exampleorg/examplebot/-/jobs/9873283596"}
setting pendingEvent status to not_sent in !xRoABCDEFGHIJKLMNO:example.org event ID ~!xRoABCDEFGHIJKLMNO:example.org:m1745974351866.0 -> undefined
{"level":50,"time":1745974351869,"pid":182,"hostname":"runner--azerasq-project-69387289-concurrent-0","name":"CI job #9873283596 for exampleorg/examplebot","msg":"Error sending event"}
{"level":30,"time":1745974469864,"pid":182,"hostname":"runner--azerasq-project-69387289-concurrent-0","name":"CI job #9873283596 for exampleorg/examplebot","msg":"Sending to !xRoABCDEFGHIJKLMNO:example.org: Bot from CI job exiting"}
setting pendingEvent status to not_sent in !xRoABCDEFGHIJKLMNO:example.org event ID ~!xRoABCDEFGHIJKLMNO:example.org:m1745974469864.1 -> undefined
{"level":50,"time":1745974469870,"pid":182,"hostname":"runner--azerasq-project-69387289-concurrent-0","name":"CI job #9873283596 for exampleorg/examplebot","msg":"Error sending event"}
{"level":30,"time":1745974471865,"pid":182,"hostname":"runner--azerasq-project-69387289-concurrent-0","name":"CI job #9873283596 for exampleorg/examplebot","msg":"Exiting after 120000 ms."}

@xurizaemon
Copy link
Collaborator Author

I was also hitting rate limiting earlier. 580a780 was an attempt to handle this by reducing online presence announcements (which probably don't need to happen for each message as they did), but that didn't address the issue for me, so I disabled presence feature entirely in 6291a8f. We could use a flag to allow this to be adapter configurable via HUBOT_MATRIX_PRESENCE_ENABLED or something?

Here's the error I was seeing (now resolved, or worked around at least):

429 too many requests error
e2e integration > file:///gcl-builds/node_modules/matrix-js-sdk/lib/http-api/utils.js:78
e2e integration >     return new MatrixError(JSON.parse(body), response.status, isXhr(response) ? response.responseURL : response.url, undefined, httpHeaders);
e2e integration >            ^
e2e integration > 
e2e integration > M_LIMIT_EXCEEDED: MatrixError: [429] Too many requests (https://matrix-client.matrix.org/_matrix/client/v3/presence/%40example%3Aexample.org/status)
e2e integration >     at parseErrorResponse (file:///gcl-builds/node_modules/matrix-js-sdk/lib/http-api/utils.js:78:12)
e2e integration >     at file:///gcl-builds/node_modules/matrix-js-sdk/lib/http-api/fetch.js:342:15
e2e integration >     at Generator.next (<anonymous>)
e2e integration >     at asyncGeneratorStep (/gcl-builds/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:17)
e2e integration >     at _next (/gcl-builds/node_modules/@babel/runtime/helpers/asyncToGenerator.js:17:9)
e2e integration >     at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
e2e integration >   httpStatus: 429,
e2e integration >   httpHeaders: Headers {},
e2e integration >   url: 'https://matrix-client.matrix.org/_matrix/client/v3/presence/%40example%3Aexample.org/status',
e2e integration >   event: undefined,
e2e integration >   errcode: 'M_LIMIT_EXCEEDED',
e2e integration >   data: {
e2e integration >     errcode: 'M_LIMIT_EXCEEDED',
e2e integration >     error: 'Too many requests',
e2e integration >     retry_after_ms: 9924
e2e integration >   }
e2e integration > }
e2e integration > 
e2e integration > Node.js v22.15.0

@xurizaemon xurizaemon force-pushed the update-esm branch 23 times, most recently from 98966cd to 12c24a5 Compare June 21, 2025 03:11
@xurizaemon xurizaemon force-pushed the update-esm branch 6 times, most recently from 49f5015 to ac3728a Compare June 21, 2025 07:12
@xurizaemon xurizaemon marked this pull request as ready for review June 21, 2025 10:42
@xurizaemon
Copy link
Collaborator Author

I got this to a point where I was happy to merge it in my own fork. Will be giving it a bit more testing, but seems to work. Now has integration tests so I can run a test from CI and see it log into a Matrix server (requires configuring a few secrets in the Github repo).

image

xurizaemon#1

@xurizaemon xurizaemon changed the title Draft: Update to ESM Updates for recent Hubot Jun 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant