Skip to content

Bug: UUID creation throws on the client #636

Description

@reinhard-sanz

Describe the bug

Essentially every UUID constructor throws ReferenceError: SharedArrayBuffer is not defined on non-cross-origin-isolated pages

In @surrealdb/sqon (Uuid constructor), the line if (uuid instanceof ArrayBuffer || uuid instanceof SharedArrayBuffer) references SharedArrayBuffer unguarded. On any page that isn't cross-origin isolated, that global doesn't exist, and evaluating the instanceof right-hand operand throws a ReferenceError before any comparison happens. This essentially means that every client-side Uuid construction throws.

Fix is a one-token guard: typeof SharedArrayBuffer !== 'undefined' && uuid instanceof SharedArrayBuffer.

Steps to reproduce

Try to create any UUID on the client on non-cross-origin-isolated pages.

Expected behaviour

UUID creation works

SurrealDB version

3.1.5 for macos on aarch64

JavaScript SDK version

2.0.4

Contact Details

No response

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct (repository /surrealdb.js)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions