Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add node:buffer imports where missing #1518

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jokull
Copy link

@jokull jokull commented Nov 16, 2023

This is an issue on workerd runtime (Cloudflare Workers). It came up before and was fixed with the same import statement in in drizzle-orm/src/sqlite-core/columns/blob.ts. Now Buffer is being used in two new places.

On this note ... I do wonder if we should be avoiding Buffer to begin with and using Uint8Array instead. See recent-ish blog post from Sindre Sorhus.

Buffer also comes with additional caveats. While Uint8Array#slice() creates an immutable copy, Buffer#slice() creates a mutable segment linked to the original Buffer, resulting in possible unpredictable behavior. The problem is not the behavior of the Buffer#slice() method, but the fact that Buffer is a subclass of Uint8Array and completely changes the behavior of an inherited method. Instead of Buffer#slice(), use Uint8Array#subarray() or Buffer#subarray(). Furthermore, buffers expose private information through global variables, a potential security risk.

It is time to move on.

@jokull
Copy link
Author

jokull commented May 29, 2024

Ok cloudflare workers is actually fixing this with improved node compatibility - still think Buffer should be avoided.

https://x.com/jasnell/status/1795872790962385390

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant