Skip to content

Uncaught ReferenceError: Buffer is not defined #72

Open

Description

@KennethJamesCurrie

When using SqlString.raw the error "Uncaught ReferenceError: Buffer is not defined" is throwing when using SqlString in a react site.

This was discovered with react 17, vite 7. Interestingly the vitest tests did not have this issue indicating that the polyfill was not supplying the buffer when running the site directly but was when running the tests.

Image

If I manually add buffer to the window prior to running the raw method I don't have a problem, but I shouldn't need to implement a workaround in order to use the library's functionality.

Image

Activity

  1. sidorares commented on Mar 16, 2026

    @sidorares
    Member

    Can you give more context on how you plan to use this library? It was not designed to be used from browser runtime

  2. KennethJamesCurrie commented on Mar 16, 2026

    @KennethJamesCurrie
    Author

    I've been asked to make a site that takes linked tables from DB and allows the user to generate scripts for create/update/delete. In most cases I have the fields I need, but in some cases I need to swap a number for a variable due to identity fields being used as FK.

    Your library does most of what I need, except for when I try to use the raw method to swap out the number for a variable.

  3. sidorares commented on Mar 17, 2026

    @sidorares
    Member

    Are you trying to access DB directly from the browser?

  4. KennethJamesCurrie commented on Mar 17, 2026

    @KennethJamesCurrie
    Author

    No, generating SQL files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions