docker-api icon indicating copy to clipboard operation
docker-api copied to clipboard

Image pull stream comes in batches, not one by one

Open MartinMuzatko opened this issue 5 years ago • 0 comments

I noticed today, that using promisifyStream, the messages don't come one by one. This makes it hard to parse and work on the JSON strings of pull messages.

It looks like this when .split('\r\n')

[ '{"status":"Pulling from library/hello-world","id":"latest"}' ]
[
  '{"status":"Pulling fs layer","progressDetail":{},"id":"1b930d010525"}'
]
[
  '{"status":"Downloading","progressDetail":{"current":473,"total":977},"progress":"[========================\\u003e                          ]     473B/977B","id":"1b930d010525"}',
  '{"status":"Downloading","progressDetail":{"current":977,"total":977},"progress":"[==================================================\\u003e]     977B/977B","id":"1b930d010525"}',
  '{"status":"Verifying Checksum","progressDetail":{},"id":"1b930d010525"}',
  '{"status":"Download complete","progressDetail":{},"id":"1b930d010525"}'
]
[
  '{"status":"Extracting","progressDetail":{"current":977,"total":977},"progress":"[==================================================\\u003e]     977B/977B","id":"1b930d010525"}',
  '{"status":"Extracting","progressDetail":{"current":977,"total":977},"progress":"[==================================================\\u003e]     977B/977B","id":"1b930d010525"}'
]
[
  '{"status":"Pull complete","progressDetail":{},"id":"1b930d010525"}'
]
[
  '{"status":"Digest: sha256:9572f7cdcee8591948c2963463447a53466950b3fc15a247fcad1917ca215a2f"}'
]
[
  '{"status":"Status: Downloaded newer image for hello-world:latest"}'
]

Is there a way to make the fn in stream.on('data', fn) only receive single objects?

Thanks in advance!

MartinMuzatko avatar Jan 24 '20 11:01 MartinMuzatko