Skip to content

Javascript live query stopping updates #596

@cbishopvelti

Description

@cbishopvelti

What component does this affect?

SurrealDB Server

Describe the bug

When running a live query from the javascript SDK, it can cause updates pushed from a separate client to fail.

Steps to reproduce

const accountId = new RecordId("account", "u8idykv574ut278gjj4f")

            const testResponse = await db.db.query("SELECT * FROM account WHERE id = type::record($accountId);", {
                accountId: accountId.toString()
            })
            console.log("001", testResponse) // WORKS FINE

            console.log("002 id", accountId, accountId.toString())
            const response = await db.db.query<[Uuid]>(
                // From Surrealist I'm running:
                // UPDATE type::record('account:u8idykv574ut278gjj4f') MERGE {
                //     updated_at: time::now()
                // };
                // This crashes the update I'm pushing from surrealist, with the error:
                // 'Expected a record but cannot convert NONE into a record'
                // I don't feel a client query should be able to affect an update from a separate client???
                // and it doesn't fire my subscription.
                "LIVE SELECT * FROM account WHERE id = type::record($accountId);",
                {
                    accountId: accountId.toString()
                }
            );

            // This works compleatly fine. Fires my subscription as expected.
            // const response = await db.db.query<[Uuid]>(
            //     "LIVE SELECT * FROM account WHERE id = type::record('account:u8idykv574ut278gjj4f')"
            // );

            const liveQueryUuid = response[0];

            live = await db.db.liveOf(liveQueryUuid);
            live.subscribe(() => {
                console.log("PLEASE HAPPEN")
            })

Expected behaviour

Expected behaviour is surrealist update completes as expected, and I don't receive 'Expected a record but cannot convert NONE into a record'.

SurrealDB version

2.6.3 on Ubuntu, javascript sdk: 2.0.3

Contact Details

Could this be a bug with your application?

  • I confirm this is a bug with SurrealDB, not with my own application

Is there an existing issue for this?

  • I confirm that I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions