question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Serialize Uint8Arrays better

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 1.3.0
  • Platform / OS version: macOS Sierra
  • URLs (if applicable): …
  • Node.js version: master

What steps will reproduce the problem?

Please include code that reproduces the issue.

  1. Open a new page with puppeteer
  2. Run page.evaluate(() => new Uint8Array(1024 * 1024 * 10)

What is the expected result?

Puppeteer takes over 20 seconds to serialize/deserialize 10MB and the resulting object is not a Uint8Array.

What happens instead?

A Uint8Array should be returned and it should take a reasonable amount of time (single-digit miliseconds tops and not seconds).


This basically would require inspecting objects returned from evaluate, detecting they’re Uint8Arrays and then serializing them differently.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:10
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
benjamingrcommented, Oct 1, 2019

why are you using JSON - I I though you were dealing with array buffer and binary data iin which case could you just write the buffer directly and consume it as array buffer in the browser ?

Yes of course I was just giving an example - my real code writes a node stream and reads it as a stream on the other side using fetch and even backpressure works (I process as quickly as I can on the client and read).

1reaction
aslushnikovcommented, Apr 26, 2018

@aslushnikov please consider reopening this issue.

Sure!

My use case for moving a lot of data is very real, it’s not farfetched at all and I believe it’s pretty common.

Feel free to send a PR

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sending Uint8Array (BSON) in a JSON object
I'm using the 'bson' npm package in the browser for converting / serializing a JSON object to BSON ...
Read more >
How to serialize that $%*#ing Buffer
Split the string on the commas into an array and use the from method of the TypedArray to get a Uint8Array . const...
Read more >
Uint8Array - JavaScript - MDN Web Docs
Chrome Edge Uint8Array Full support. Chrome7. Toggle history Full support. Edge12... Uint8Array() constructor Full support. Chrome7. Toggle history Full support. Edge12... Constructor without parameters Full support....
Read more >
stdlib: JSON Serialization and Deserialization of Exotic ...
Notably, JSON only supports a subset of JavaScript; specifically: plain objects, arrays, strings, numbers, booleans, and null . More exotic objects available in ......
Read more >
chainsafe/ssz
length 48 // serialize the object to a byte array const serialized: Uint8Array = Keypair.serialize(keypair); // get the merkle root of the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found