WordPress / WordPress/wordpress-playground

Blueprints: Streaming zip/unzip for browser and server

Open
#482 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

[Package][@wp-playground] Blueprints [Type] Enhancement [Type] Mindmap Node
Dominant language
JavaScript
Stars
2k
Forks
462
Avg merge
18h 44m
Merged PRs (30d)
33

Description

Currently, the blueprint step unzip requires a path to the zip file. It would be useful to add support for passing a Stream.

It has advantages in terms of speed and memory use, in that it starts unzipping as data comes in instead of buffering it all in memory, writing it to a temporary file, then passing the path.

Another common use case is when the caller of unzip has a File instance, which cannot be passed as is. I suppose in this case it would be useful to be able to pass the File instance instead of creating a stream from it, or writing/copying it to the file system.

..didn't we pipe the zip file in another PR straight into unzip so we could skip the temporary file?

that happens in wp-now and cannot be easily done with Blueprints yet because the "resource" abstraction outputs a File object. Also, the zip stream was node-specific. Figuring this out would be a great follow-up, though.

Loosely thinking, maybe a "zipped resource type" or the ability to output a stream from a regular resource would do the trick.

A difficulty is that Stream is available only on Node.js. While a port to the browser exists (readable-stream), I'm guessing it doesn't do what we need, which is to stream data from JavaScript to PHP/WASM - and vice versa.

..If the File instance has the file content in memory on JS side, maybe it can be passed directly to WASM as a transferable object instead of copying it or writing to a temporary file, and stream it to PHP somehow.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the Blueprint unzip step and the resource abstraction used by wp-now. Review the Node.js Stream, browser File, readable-stream, and PHP/WASM constraints described here. Done means defining and validating a supported way to pass zip data without temporary-file buffering across the browser and server paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, php, wasm
Domain
full-stack, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.