question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

type information is wrong for RealtimePostgresChangesPayload

See original GitHub issue

Bug report

Not sure if this belongs here or in supabase/supabase-js.

Describe the bug

When using realtime subscriptions with v2.0.0 of supabase-js the payload type (RealtimePostgresChangesPayload) does not match how the payload actually looks like.

When inspecting the payload in the browser it looks like this: image

But RealtimePostgresChangesPayload looks like this and does not contain e.g. record, old_record, columns etc from the actual payload.

export type RealtimePostgresChangesPayload<T extends { [key: string]: any }> = {
  schema: string
  table: string
  commit_timestamp: string
  eventType:
    | `${REALTIME_POSTGRES_CHANGES_LISTEN_EVENT.INSERT}`
    | `${REALTIME_POSTGRES_CHANGES_LISTEN_EVENT.UPDATE}`
    | `${REALTIME_POSTGRES_CHANGES_LISTEN_EVENT.DELETE}`
  new: T | {}
  old: Partial<T> | {}
  errors: string[]
}

Even worse: old and new are present but always undefined. So with the current state of the type I do not even get the data I need.

Expected behavior

RealtimePostgresChangesPayload should reflect the actual payload type.

System information

  • Version of supabase-js: 2.0.0
  • Version of Node.js: 16.14.2

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:6
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
w3b6x9commented, Oct 18, 2022

I encountered this locally using the CLI v1.6.0.

@samuba existing CLI’s Realtime is not yet compatible with supabase-js v2. Try it with the hosted Supabase when ready.

The docs are currently not documenting the payload type at all. Only the parameters.

Thanks, will take a look.

0reactions
guillaume86commented, Dec 10, 2022

Same issue here with the self hosted docker images and realtime-js@2.1.0. Any news for a update?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · supabase/realtime-js - GitHub
type information is wrong for RealtimePostgresChangesPayload bug Something isn't ... Ability to Generate Typescript Type Declarations from Server Schema ...
Read more >
Supabase realtime-js Issues - Giters
type information is wrong for RealtimePostgresChangesPayload. Updated 23 days ago 9 ... Can't subscribe to database changes due to type ambivalence.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found