Visitar URL original
Replace `concat-stream` w/ `node:stream/consumers` by ChristianMurphy · Pull Request #93 · unifiedjs/unified-engine · GitHub
Skip to content

Replace concat-stream w/ node:stream/consumers - #93

Open
ChristianMurphy wants to merge 1 commit into
unifiedjs:mainfrom
ChristianMurphy:refactor/replace-concat-stream
Open

ChristianMurphy wants to merge 1 commit into
unifiedjs:mainfrom
ChristianMurphy:refactor/replace-concat-stream

Conversation

@ChristianMurphy

Copy link
Copy Markdown
Member

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and discussions and couldn’t find anything or linked relevant results below
  • I made sure the docs are up to date
  • I included tests (or that’s not needed)

Description of changes

Closes GH-92.

stdin.js now reads streamIn with text() from node:stream/consumers instead of piping it into concat-stream.
concat-stream and @types/concat-stream leave dependencies, so CLI users no longer install them.
The stdin.js diff is easier to read with whitespace hidden: the callback body moved one indent level.

next is the second argument to .then(), as in lib/finder.js, not a .catch().
trough runs next once, so a .catch(next) would silently drop a throw that happens after next().
With .then(), that throw stays visible as an unhandled rejection.

Behavior changes:

  • An error on streamIn now rejects the engine with that error.
    Before, .pipe() did not forward it and the process crashed with an uncaught exception.
    The new test in test/input.js covers this and fails on main.
  • text() decodes with TextDecoder, which drops a leading UTF-8 byte order mark (BOM) on stdin.
    Files read from disk keep theirs.
    micromark and parse5 strip a BOM when parsing, so remark and rehype output stays the same.
  • An object-mode streamIn now rejects with a TypeError.
    concat-stream turned such chunks into [object Object].
  • A classic stream without Symbol.asyncIterator, such as a bare new Stream(), now rejects with TypeError: stream is not async iterable.
    streamIn accepts a NodeJS.ReadableStream, and that interface already requires Symbol.asyncIterator.
    Callers can wrap such a stream with new Readable().wrap(stream).
  • The module needs Node.js 16.7 or later to load, which is when node:stream/consumers landed.
    CI runs Node.js 18 and latest.

@github-actions github-actions Bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Sep 26, 2026
@codecov

codecov Bot commented Sep 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (6f35eae) to head (13b2fd6).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #93   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           23        23           
  Lines         3214      3212    -2     
=========================================
- Hits          3214      3212    -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wooorm

wooorm commented Sep 26, 2026

Copy link
Copy Markdown
Member

can you tag your issues/prs with patch/minor/major labels btw? Makes it easier to not have accidents!

@ChristianMurphy ChristianMurphy added the 👶 semver/patch This is a backwards-compatible fix label Sep 26, 2026
@ChristianMurphy

Copy link
Copy Markdown
Member Author

On it 🫡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤞 phase/open Post is being triaged manually 👶 semver/patch This is a backwards-compatible fix

Development

Successfully merging this pull request may close these issues.

Replace concat-stream with text() from node:stream/consumers

2 participants