---
title: "Alice is demoted, the subscription stays open"
url: "https://www.mikefluff.com/en/experiments/js-ch16-revocation"
locale: "en"
author: "Mikhail Savchenko (Mike Fluff)"
updated: "2026-11-18"
description: "Access revocation and role-based access control in real-time data"
book: "https://www.mikefluff.com/en/books/from-closures-to-autonomous-systems"
alternates:
  - locale: "en"
    url: "https://www.mikefluff.com/en/experiments/js-ch16-revocation"
    markdown: "https://www.mikefluff.com/en/experiments/js-ch16-revocation.md"
  - locale: "ru"
    url: "https://www.mikefluff.com/ru/experiments/js-ch16-revocation"
    markdown: "https://www.mikefluff.com/ru/experiments/js-ch16-revocation.md"
  - locale: "pt"
    url: "https://www.mikefluff.com/pt/experiments/js-ch16-revocation"
    markdown: "https://www.mikefluff.com/pt/experiments/js-ch16-revocation.md"
  - locale: "es"
    url: "https://www.mikefluff.com/es/experiments/js-ch16-revocation"
    markdown: "https://www.mikefluff.com/es/experiments/js-ch16-revocation.md"
---

# Alice is demoted, the subscription stays open

*Access revocation and role-based access control in real-time data*

## What does revoking access actually revoke?

Revoking access withdraws a permission that was granted earlier, for example by taking a role away from a user. It applies to what happens next: the system stops answering that user’s requests for the data and, in a real-time app, stops sending changes and tells the client to drop documents it may no longer see. It cannot reach data that was already delivered. Whatever the client copied before the revocation, into an export, a cache or a screenshot, stays where it is. That is why the safer question is what to send to the client in the first place.

In Meteor the read permission lived in a publication function: what it returned went to the client’s Minimongo. The function ran when the client subscribed and again when the user logged in or out. A role lies in an ordinary database document, so changing it while the subscription is open went unnoticed, and a demoted user kept receiving everything until they reloaded the page. The experiment is a toy model of such a publication inspired by Meteor, not Meteor itself.

Press “Start”: ten orders, three of them Alice’s, the server changing one order’s amount every 20 ms. While the clock runs, save a copy of the client data and demote Alice, in either order, or play the book’s script. The left client is subscribed to a publication that read the role once, the right one to a publication that reruns when the role changes and sends removed for the excess. The counters show how many orders each copy holds and how many updates of other people’s orders arrived after the demotion.

In the book, in Node 24.16.0, the copy was saved at 50 ms and Alice was demoted at 100 ms. With the static publication her copy still held 10 orders and 13 updates of others’ orders arrived during the 400 ms that followed. With the reactive one 3 orders were left and 0 foreign updates arrived. The copy saved before the demotion held 7 foreign orders in both modes.

The chapter’s conclusion is that only the future can be revoked. The server can stop sending updates and ask the client to forget what it sent, but data that has reached another machine is already copied. PostgreSQL row security and Supabase later moved the access rule into the database, which checks it on every query and every change, and they cannot recall delivered data either. The fewer fields and documents a subscription sends, the less there is to revoke.

_The page has an interactive experiment that runs in a browser: https://www.mikefluff.com/en/experiments/js-ch16-revocation_

## Sources

- [Role-based access control (Wikipedia)](https://en.wikipedia.org/wiki/Role-based_access_control)
- [PostgreSQL documentation, Row Security Policies](https://www.postgresql.org/docs/current/ddl-rowsecurity.html)
- [Meteor, DDP specification (DDP.md)](https://github.com/meteor/meteor/blob/devel/packages/ddp/DDP.md)

## From the book

Beside it in the book:

> Only the future can be revoked. While the subscription is open, the server can stop sending changes and ask the client to forget what it already sent. But data that has reached someone else’s machine has already been copied, and it cannot be made to disappear; you can only ask. So the question of what to do when permissions are revoked really comes down to a different question: what should have been sent to the client at all. The fewer fields and documents go out in a subscription, the less there will be to revoke later. We will come back to this in the interlude after the seventeenth chapter.

- Read the chapter: [Chapter 16. Reactivity Under Access Control](https://www.mikefluff.com/en/read/from-closures-to-autonomous-systems/ch16) (opening free, rest in the full book; Markdown: https://www.mikefluff.com/en/read/from-closures-to-autonomous-systems/ch16.md)

- Book: [JavaScript: From Closures to Autonomous Systems](https://www.mikefluff.com/en/books/from-closures-to-autonomous-systems)
