hasura / hasura/graphql-engine

Server: Subscription not updating properly when table select permission based on `now()`

Open
#8,716 0 comments 0 reactions 0 assignees View on GitHub
c/server k/bug t/native-dbs
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Version Information

Server Version: 2.8.4

### Environment

OSS

### What is the current behaviour?

A subscription against a table that has a time-sensitive select permission - based on `now()` - doesn't update when it should.

### What is the expected behaviour?

The subscription should update the results of the query as soon as the select permission filter evaluates to true (within 1 second assuming the default server configuration).

### How to reproduce the issue?

In Hasura console:
1. Create a new table `alerts` with default `id` PK
2. Add a new column `show_at` to the table - Timestamp, not null, default now()
3. Add a select permission to the table `{"show_at":{"_lte":"now()"}}`
4. Run a subscription against the table `subscription { alerts { id, show_at }}`
5. Insert a new record into the table, using the default value of `now()` for `show_at`

The subscription should show the new record almost immediately but it doesn't. It eventually shows up some time later.

It seems like the value of `now()` on the permission isn't re-evaluated each time the subscription is.

### Keywords

subscription select permission now()

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the `alerts` table and the `subscription { alerts { id, show_at } }` query, then trace when the `{"show_at":{"_lte":"now()"}}` permission is evaluated. Done means the subscription exposes the inserted row almost immediately when the time-based filter becomes true; the payload names no source files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, postgresql
Domain
api, authorization, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.