Skip to content

Read ephemeral events from the stable transaction key#84

Merged
AndrewFerr merged 3 commits into
matrix-org:developfrom
lequocbinh04:fix-stable-ephemeral-key
Jul 2, 2026
Merged

Read ephemeral events from the stable transaction key#84
AndrewFerr merged 3 commits into
matrix-org:developfrom
lequocbinh04:fix-stable-ephemeral-key

Conversation

@lequocbinh04

@lequocbinh04 lequocbinh04 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Description

Ephemeral events (typing, receipts, presence) are delivered to application services under the stable ephemeral key in the transaction body, per the Matrix application service spec (the stabilisation of MSC2409). However AppService.onTransaction only reads the legacy unstable key de.sorunome.msc2409.ephemeral.

As a result, ephemeral events from spec-compliant homeservers are silently dropped — onEphemeralEvent / the ephemeral emitter never fire. I hit this building a bridge against Beeper's hungryserv (which sends the stable key): read receipts and typing never reached the bridge. Synapse also sends the stable key.

Change

Read req.body.ephemeral first, falling back to req.body["de.sorunome.msc2409.ephemeral"] for older homeservers. Adds tests covering both keys and the precedence.

npm run build, lint, and npm test all pass.

Signed-off-by: Lê Quốc Bình lequocbinh04@users.noreply.github.com

Homeservers deliver ephemeral events (typing, receipts, presence) to
appservices under the stable `ephemeral` key in the transaction body per the
Matrix spec, but onTransaction only read the unstable
`de.sorunome.msc2409.ephemeral` key. Modern homeservers (e.g. Synapse, and
Beeper's hungryserv) send the stable key, so ephemeral events were silently
dropped. Read the stable key with a fallback to the unstable one, and add tests.
@lequocbinh04 lequocbinh04 requested a review from a team as a code owner July 2, 2026 13:19

@AndrewFerr AndrewFerr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is indeed a helpful fix. Thank you for contributing it!

There is just one small nitpick change I'll request, and one optional suggestion.

Also, don't forget to sign off this PR. The easiest way is to add a Signed-off-by line to the top comment of the PR.

Comment thread src/app-service.ts Outdated
const ephemeral = req.body["de.sorunome.msc2409.ephemeral"] || [];
// Ephemeral events are delivered under the stable `ephemeral` key by
// spec-compliant homeservers; fall back to the unstable MSC2409 key for
// older ones. See https://spec.matrix.org/v1.11/application-service-api/#put_matrixappv1transactionstxnid

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The ephemeral key was added in v1.13 of the spec, so the link should point to at least that version.

Suggested change
// older ones. See https://spec.matrix.org/v1.11/application-service-api/#put_matrixappv1transactionstxnid
// older ones. See https://spec.matrix.org/v1.13/application-service-api/#put_matrixappv1transactionstxnid

Comment thread test/test_app-service.ts
Signed-off-by: Lê Quốc Bình <lequocbinh04@users.noreply.github.com>
@lequocbinh04

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Addressed both points:

  • Spec link now points to v1.13 (where the ephemeral key was added).
  • Receipt test fixtures now use a non-empty m.read content via a mockReceipt() helper.

Signed-off-by: Lê Quốc Bình lequocbinh04@users.noreply.github.com

@lequocbinh04 lequocbinh04 requested a review from AndrewFerr July 2, 2026 17:46
@AndrewFerr

Copy link
Copy Markdown
Member

Ah, the Signoff job is failing because it's still on an older version that runs into false positives. That will be fixed by #81. Merging this PR in the meantime.

Thanks again!

@AndrewFerr AndrewFerr merged commit 96bbdda into matrix-org:develop Jul 2, 2026
4 of 9 checks passed
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.

2 participants