B
B
Bogdan2020-01-03 19:28:30
Node.js
Bogdan, 2020-01-03 19:28:30

Does Stream.pipeline always return [ERR_STREAM_PREMATURE_CLOSE]?

Hello. Don't tell me?
*stream.pipeline* always returns Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close . Although the stream threw an exception new Error('destroy') .
In a real application, a large file is being downloaded, sometimes the server drops the connection by timeout, and when using stream.pipeline, it is not clear what error occurred, ERR_STREAM_PREMATURE_CLOSE is always returned.

Node.js: 15.5.0
Platform: Ubuntu 20.10 x64

/* eslint-disable */
import http from 'https';
import { createWriteStream } from 'fs';
import { pipeline } from 'stream/promises';

const httpRequest = url => new Promise(resolve => http.get(url, res => resolve(res)));

const FILENAME_TMP = './1.tmp'
const linkFile = 'https://nodejs.org/dist/v15.5.0/node-v15.5.0-linux-x64.tar.xz';

const downloadStream = await httpRequest(linkFile, { responseType: 'stream' });

// view error
downloadStream.on('error', err => console.log('onError', err));

// break download
setTimeout(() => downloadStream.destroy(new Error('destroy')), 1000);

try {
  await pipeline(
    downloadStream,
    createWriteStream(FILENAME_TMP)
  );

  console.log('Done');
} catch (err) {
  console.log('onPipeline', err);
}


onError Error: destroy
    at Timeout._onTimeout (file:///home/user/Project/ufopParser/3.js:17:41)
    at listOnTimeout (node:internal/timers:556:17)
    at processTimers (node:internal/timers:499:7)
onPipeline Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
    at new NodeError (node:internal/errors:278:15)
    at IncomingMessage.onclose (node:internal/streams/end-of-stream:117:38)
    at IncomingMessage.emit (node:events:376:20)
    at IncomingMessage._destroy (node:_http_incoming:169:10)
    at _destroy (node:internal/streams/destroy:67:23)
    at IncomingMessage.destroy (node:internal/streams/destroy:59:5)
    at Timeout._onTimeout (file:///home/user/Project/ufopParser/3.js:17:33)
    at listOnTimeout (node:internal/timers:556:17)
    at processTimers (node:internal/timers:499:7) {
  code: 'ERR_STREAM_PREMATURE_CLOSE'
}


Thanks

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey Goryachev, 2017-03-17
@webirus

kenwheeler.github.io/slick
Center Mode
arrows: false
controls: false
And I don't understand why you don't like it.
But judging by the description, you just don't cook it that way.
Resolved via CSS override.

O
Oleg, 2017-03-17
@nugget-ekb

the convenience of this carousel is a big question! I always use the owl carousel for the carousel. for all my tasks it has always been suitable.

E
Egor Zhivagin, 2017-03-17
@Krasnodar_etc

The central block is scaled up by transform scale, which takes relative values ​​as values, not exact ones. As a result, the central unit has an error, albeit not a significant one.

- With your css, add any necessary styles to the .slick-center block
- So you yourself can make them at least with margins in pixels in their styles)
Slick is good because it is quite simply customizable / corrected by ordinary css. And you don't even have to go into the plugin files)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question