e2b-dev / E2B

Secure open source cloud runtime for AI apps & AI agents
https://e2b.dev/docs
Apache License 2.0
7.02k stars 458 forks source link

Use `Buffer.from()` when writing a file #360

Closed ggorlen closed 4 months ago

ggorlen commented 7 months ago

Running the JS file download snippet in Node 20 gave me:

Uncaught:
TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of ArrayBuffer

on writeFileSync.

But using Buffer.from(buffer) fixed the issue and wrote the CSV file successfully. I haven't tested this extensively since I'm working with a remote client who's using the library on his end, so more validation that this change makes sense would be good before merging (this may be specific to our text file use case).

changeset-bot[bot] commented 7 months ago

⚠️ No Changeset found

Latest commit: 7b50ddb6c955660b0bc242b7f59af9151ac7488b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

[Click here if you're a maintainer who wants to add a changeset to this PR](https://github.com/ggorlen/E2B/new/use-buffer-from?filename=.changeset/wise-pumpkins-fetch.md&value=---%0A%0A---%0A%0AUse%20%60Buffer.from()%60%20when%20writing%20a%20file%0A)

ValentaTomas commented 7 months ago

Hey @ggorlen, thank you for catching this and opening the PR! We will check this out 👌