Skip to content

feat(DEP0157): add codemod for stream implementation to callback base… - #545

Open
Harshall25 wants to merge 4 commits into
nodejs:mainfrom
Harshall25:feat/stream-thenable-to-callback
Open

Harshall25 wants to merge 4 commits into
nodejs:mainfrom
Harshall25:feat/stream-thenable-to-callback

Conversation

@Harshall25

Copy link
Copy Markdown

This PR adds a codemod for DEP0157 to convert async/thenable-based stream implementations to callback-based implementations.

Changes

  • Detects Writable, Readable, Transform, Duplex, and PassThrough stream implementations.
  • Handles _write, _writev, _read, _transform, _flush, and _final, including their option-object methods .
  • Converts sequential await operations into promise chains and ensures callbacks are invoked correctly.
  • Handles error paths using callback(err) and this.destroy(err) for read implementations.
  • Preserves existing comments and formatting.

Added tests covering all 9 examples from the issue.

Closes #410

Copilot AI balanced review requested due to automatic review settings October 7, 2026 19:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@AugustinMauroy AugustinMauroy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super cool !

Comment thread recipes/stream-thenable-to-callback/src/workflow.ts
Comment thread recipes/stream-thenable-to-callback/src/workflow.ts Outdated
Comment thread recipes/stream-thenable-to-callback/src/workflow.ts Outdated
Comment thread recipes/stream-thenable-to-callback/src/workflow.ts Outdated
Comment thread recipes/stream-thenable-to-callback/src/workflow.ts Outdated
Comment thread recipes/stream-thenable-to-callback/src/workflow.ts Outdated
Comment on lines +3 to +9
const stream = new Writable({
"write": async function (chunk, encoding, callback)
{
await save(chunk);
callback();
},
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can add similar cases

Suggested change
const stream = new Writable({
"write": async function (chunk, encoding, callback)
{
await save(chunk);
callback();
},
});
const stream = new Writable({
"write": async function (chunk, encoding, callback)
{
await save(chunk);
callback();
},
});
cconst stream2 = new Writable({
"write": async (chunk, encoding, callback) => {
await save(chunk);
callback();
},
});

@AugustinMauroy AugustinMauroy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGMT !

@AugustinMauroy AugustinMauroy added the awaiting reviewer Author has responded and needs action from the reviewer label Oct 11, 2026
@AugustinMauroy
AugustinMauroy requested a review from a team October 11, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviewer Author has responded and needs action from the reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Thenable support in streams

3 participants