8000 refactor!: use Uint8Array instead of Buffer for browser compatibility by Lightning00Blade · Pull Request #12823 · puppeteer/puppeteer · GitHub
[go: up one dir, main page]

Skip to content

refactor!: use Uint8Array instead of Buffer for browser compatibility #12823

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

Merged
merged 15 commits into from
Aug 6, 2024

Conversation

Lightning00Blade
Copy link
Collaborator
@Lightning00Blade Lightning00Blade commented Jul 24, 2024

We want users to be able to use Puppeteer in different environments, most notably in the browser.
Therefore, we want to move away from Node-specific API and rely on the ECMAScript APIs more and this
change replaces Node's Buffer in various Puppeteer APIs with Uint8Array.

If you want to convert Uint8Array to Buffer, call Buffer.from. For example, instead of

const buffer = await page.screenshot();

convert to Buffer explicitly:

const buffer = Buffer.from(await page.screenshot());

Many Node APIs accept Uint8Arrays so it should not be needed unless you want to use Buffer-specific APIs.

@Lightning00Blade Lightning00Blade mentioned this pull request Jul 24, 2024
32 tasks
@Lightning00Blade Lightning00Blade changed the title refactor!: change Buffer to Uint8Array refactor!: use Uint8Array instead of Buffer for compatability Jul 24, 2024
@Lightning00Blade Lightning00Blade changed the title refactor!: use Uint8Array instead of Buffer for compatability refactor!: use Uint8Array instead of Buffer for compatibility Jul 24, 2024
@Lightning00Blade Lightning00Blade force-pushed the change-to-uint8array branch 3 times, most recently from 5791f05 to 17ea82a Compare August 6, 2024 10:54
@Lightning00Blade Lightning00Blade marked this pull request as ready for review August 6, 2024 10:54
@OrKoN OrKoN removed the DO NOT MERGE label Aug 6, 2024
@OrKoN OrKoN force-pushed the change-to-uint8array branch from db65b30 to 7aa8f0e Compare August 6, 2024 15:13
@OrKoN OrKoN changed the title refactor!: use Uint8Array instead of Buffer for compatibility refactor!: use Uint8Array instead of Buffer for browser compatibility Aug 6, 2024
@OrKoN OrKoN merged commit f3377e1 into main Aug 6, 2024
37 checks passed
@OrKoN OrKoN deleted the change-to-uint8array branch August 6, 2024 15:36
This was referenced Aug 6, 2024
@Ph0tonic
Copy link
Ph0tonic commented Aug 16, 2024

Hi,
Could it be possible to update the release note of 23.0.0 to include this breaking changes ? Juste a single line to point to this issue would be great.
It would ease the update to this release.

Thank you very much.

\cc @Lightning00Blade

@Lightning00Blade
Copy link
Collaborator Author

@Ph0tonic You can find the the changes on https://github.com/puppeteer/puppeteer/releases/tag/puppeteer-core-v23.0.0
I will investigate linking the puppeteer-core and puppeteer page in releases.

@Ph0tonic
Copy link

Ho great, thanks. Indeed, having a link to those changes would definitely help. 👍

@olivierr91
Copy link

@Lightning00Blade This also should be mentioned in the breaking changes of the CHANGELOG. Everything that breaks existing code should be listed in the breaking changes.

@Lightning00Blade
Copy link
Collaborator Author

@Lightning00Blade Again the issue is due to the puppeteer and puppeteer-core not being sync -
You can see that the puppeteer-core CHANGELOG.md includes this change.
https://github.com/puppeteer/puppeteer/blob/main/packages/puppeteer-core/CHANGELOG.md#2300-2024-08-07

Issue tracked at - #12989

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.

4 participants
0