Skip to content

fix(ext/node): allow omitting arguments in base64Slice#34318

Merged
bartlomieju merged 1 commit into
denoland:mainfrom
turtletongue:fix/allow-omitting-args-in-base64slice
May 25, 2026
Merged

fix(ext/node): allow omitting arguments in base64Slice#34318
bartlomieju merged 1 commit into
denoland:mainfrom
turtletongue:fix/allow-omitting-args-in-base64slice

Conversation

@turtletongue

@turtletongue turtletongue commented May 23, 2026

Copy link
Copy Markdown
Contributor

Closes #34286

Summary

The offset and length parameters are optional and default to 0 and buffer.length(), respectively, as defined in node source code. This PR adds default values to these parameters to match Node.js behavior.

Followed @bddjr recommendations.

@fibibot fibibot 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.

Defaulting offset and length in Buffer.prototype.base64Slice fixes the direct call path that previously passed undefined/NaN into op_base64_encode_from_buffer; Buffer#toString("base64") still uses its existing normalized start/end dispatch. The added unit test covers the omitted-argument regression. Holding approval until CI is green.

@lunadogbot

Copy link
Copy Markdown
Contributor

node_compat::parallel::test-cluster-send-deadlock.js flaked twice, then failed with ChildProcess.send with non-TCP net.Socket handle; PR changes only buffer code. Re-running.

@fibibot fibibot 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.

CI is green now, promoting prior review to APPROVE.

@fibibot

fibibot commented May 23, 2026

Copy link
Copy Markdown
Contributor

@bartlomieju this is ready to merge

@lunadogbot lunadogbot 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.

Defaulting offset and length only when they are undefined preserves explicit-range calls while fixing buf.base64Slice() and buf.base64Slice(0, 3), which previously sent undefined/NaN into op_base64_encode_from_buffer. The unit coverage hits the omitted-argument path for both base64 and base64url, and CI is green.

@lunadogbot

Copy link
Copy Markdown
Contributor

@bartlomieju this is ready to merge

@bartlomieju
bartlomieju merged commit 5bd5a3b into denoland:main May 25, 2026
269 of 271 checks passed
littledivy pushed a commit to crowlKats/deno that referenced this pull request Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Buffer.prototype.base64Slice throws error when arguments are omitted

5 participants