Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The slicing method in the buffer.Blob is wrong according to the spec #37335

Closed
jimmywarting opened this issue Feb 12, 2021 · 0 comments
Closed

Comments

@jimmywarting
Copy link

jimmywarting commented Feb 12, 2021

  • Version: v15.8.0
  • Platform: Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:11 PDT 2020; root:xnu-7195.50.7~2/RELEASE_X86_64 x86_64
  • Subsystem:

Thought I would try it out and help you find some quirks before making it stable. The slicing method is wrong

What steps will reproduce the bug?

import { Blob } from 'buffer'

new Blob().slice(0, 500)
new Blob(['abc']).slice(-1).text()        // c
new Blob(['abc']).slice(0, -1).text()     // ab
new Blob(['abcdef']).slice(-3, -1).text() // de

How often does it reproduce?

Happens everytime

What is the expected behavior?

...to get a new Blob slice without throwing any error.
the slicing method should behave similar like you slice a String or a ArrayBuffer

But internally it can be more complicated then that if it should operate on multiple blob parts that are async (see #37338)

What do you see instead?

Uncaught:
RangeError [ERR_OUT_OF_RANGE]: The value of "end" is out of range.
It must be less than or equal to length. Received 500

This should not happen.

@targos targos self-assigned this Feb 13, 2021
targos added a commit to targos/node that referenced this issue Feb 13, 2021
targos added a commit to targos/node that referenced this issue Feb 16, 2021
targos added a commit to targos/node that referenced this issue Feb 17, 2021
@targos targos closed this as completed in 6b28985 Feb 17, 2021
targos added a commit that referenced this issue Feb 28, 2021
PR-URL: #37361
Fixes: #37335
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: James M Snell <[email protected]>
targos added a commit to targos/node that referenced this issue Aug 8, 2021
PR-URL: nodejs#37361
Fixes: nodejs#37335
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: James M Snell <[email protected]>
targos added a commit to targos/node that referenced this issue Aug 8, 2021
PR-URL: nodejs#37361
Fixes: nodejs#37335
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: James M Snell <[email protected]>
targos added a commit to targos/node that referenced this issue Aug 13, 2021
PR-URL: nodejs#37361
Fixes: nodejs#37335
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: James M Snell <[email protected]>
targos added a commit that referenced this issue Aug 13, 2021
PR-URL: #37361
Backport-PR-URL: #39704
Fixes: #37335
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this issue Aug 31, 2021
PR-URL: #37361
Backport-PR-URL: #39704
Fixes: #37335
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: James M Snell <[email protected]>
foxxyz pushed a commit to foxxyz/node that referenced this issue Oct 18, 2021
PR-URL: nodejs#37361
Backport-PR-URL: nodejs#39704
Fixes: nodejs#37335
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@targos targos removed their assignment Mar 1, 2022
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 a pull request may close this issue.

2 participants