xref: /third_party/node/test/parallel/test-stream-pipe-deadlock.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst { Readable, Writable } = require('stream');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ci// https://github.com/nodejs/node/issues/48666
71cb0ef41Sopenharmony_ci(async () => {
81cb0ef41Sopenharmony_ci  // Prepare src that is internally ended, with buffered data pending
91cb0ef41Sopenharmony_ci  const src = new Readable({ read() {} });
101cb0ef41Sopenharmony_ci  src.push(Buffer.alloc(100));
111cb0ef41Sopenharmony_ci  src.push(null);
121cb0ef41Sopenharmony_ci  src.pause();
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ci  // Give it time to settle
151cb0ef41Sopenharmony_ci  await new Promise((resolve) => setImmediate(resolve));
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci  const dst = new Writable({
181cb0ef41Sopenharmony_ci    highWaterMark: 1000,
191cb0ef41Sopenharmony_ci    write(buf, enc, cb) {
201cb0ef41Sopenharmony_ci      process.nextTick(cb);
211cb0ef41Sopenharmony_ci    }
221cb0ef41Sopenharmony_ci  });
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ci  dst.write(Buffer.alloc(1000)); // Fill write buffer
251cb0ef41Sopenharmony_ci  dst.on('finish', common.mustCall());
261cb0ef41Sopenharmony_ci  src.pipe(dst);
271cb0ef41Sopenharmony_ci})().then(common.mustCall());
28

Indexes created Thu Nov 07 10:32:03 CST 2024