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

TextDecoder seems to be incorrectly fatal=true by default? #30312

Closed
jimmywarting opened this issue Oct 26, 2021 · 3 comments
Closed

TextDecoder seems to be incorrectly fatal=true by default? #30312

jimmywarting opened this issue Oct 26, 2021 · 3 comments
Labels
bug Issue was opened via the bug report template. Middleware Related to Next.js Middleware

Comments

@jimmywarting
Copy link

jimmywarting commented Oct 26, 2021

What version of Next.js are you using?

NaN

What version of Node.js are you using?

NaN

What browser are you using?

NaN

What operating system are you using?

NaN

How are you deploying your application?

NaN

Describe the Bug

Sry, if i could not give more information about the system/version being used (I'm in non direct contact of what you have built)

A user of fetch-blob reported to us that your polyfilled version of TextDecoder is buggy node-fetch/fetch-blob#118

He said that when decoding a specific buffer that new TextDecoder().decode(buf) that it was throwing error when the default fatal option is false.

Expected Behavior

to not throw an error

To Reproduce

const uint8 = Uint8Array.from([
          0x75, 0xab, 0x5a, 0x8a, 0x66, 0xa0, 0x7b, 0xf8, 0xe9, 0x7a, 0x06, 0xda, 0xb1, 0xee, 0xb8,
          0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x00, 0x00,
          0x01, 0x00, 0x01, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01,
          0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x04, 0x03, 0x02, 0x02, 0x02,
          0x02, 0x05, 0x04, 0x04, 0x03, 0x04, 0x06, 0x05, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06,
          0x07, 0x09, 0x08, 0x06, 0x07, 0x09, 0x07, 0x06, 0x06, 0x08, 0x0b, 0x08, 0x09, 0x0a, 0x0a,
          0x0a, 0x0a, 0x0a, 0x06, 0x08, 0x0b, 0x0c, 0x0b, 0x0a, 0x0c, 0x09, 0x0a, 0x0a, 0x0a, 0xff,
          0xc2, 0x00, 0x0b, 0x08, 0x00, 0x10, 0x00, 0x10, 0x01, 0x01, 0x11, 0x00, 0xff, 0xc4, 0x00,
          0x16, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
          0x00, 0x00, 0x00, 0x05, 0x03, 0x09, 0xff, 0xda, 0x00, 0x08, 0x01, 0x01, 0x00, 0x00, 0x00,
          0x00, 0xc6, 0xea, 0x1a, 0x4f, 0xff, 0xc4, 0x00, 0x22, 0x10, 0x00, 0x01, 0x04, 0x02, 0x02,
          0x02, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0x04, 0x05,
          0x06, 0x03, 0x07, 0x08, 0x11, 0x00, 0x22, 0x12, 0x13, 0x21, 0x42, 0xff, 0xda, 0x00, 0x08,
          0x01, 0x01, 0x00, 0x01, 0x3f, 0x00, 0xd1, 0x1c, 0x47, 0xd9, 0xbc, 0x92, 0x7e, 0xdb, 0x05,
          0x5e, 0x66, 0xbd, 0x02, 0xd6, 0x46, 0x67, 0x1c, 0x3c, 0x54, 0xbd, 0xbe, 0x61, 0x18, 0x34,
          0x7f, 0x26, 0x6a, 0x1f, 0x06, 0x38, 0x32, 0x10, 0x97, 0xd9, 0x9f, 0xac, 0x80, 0x4a, 0x08,
          0x9f, 0x88, 0x48, 0xab, 0xd7, 0x69, 0xde, 0xf9, 0xe0, 0x4e, 0xe0, 0xd0, 0x3a, 0xbe, 0x4b,
          0x6d, 0x59, 0xee, 0x14, 0x99, 0x68, 0xe8, 0x5b, 0xa2, 0x55, 0x27, 0xdb, 0x56, 0x6c, 0xe0,
          0xf5, 0xcc, 0x5c, 0xaa, 0x83, 0x83, 0x4c, 0x19, 0xc0, 0x47, 0xd7, 0xd5, 0xae, 0x6f, 0xd4,
          0x55, 0xf2, 0xbf, 0xca, 0xad, 0xb9, 0x45, 0xa3, 0x54, 0xb5, 0xdc, 0x03, 0xe6, 0x23, 0x19,
          0x47, 0xd8, 0x4b, 0x74, 0x80, 0x0c, 0xac, 0x44, 0xcc, 0x25, 0x54, 0x1b, 0x87, 0xcc, 0xcb,
          0xbf, 0x7c, 0x7d, 0x35, 0xc5, 0xe9, 0xe5, 0xe3, 0x95, 0x1b, 0x72, 0xfd, 0x45, 0xb7, 0xeb,
          0xab, 0x0b, 0xe6, 0x25, 0x19, 0x76, 0xd8, 0x63, 0x75, 0x9d, 0x0c, 0x2c, 0x44, 0x0c, 0xe5,
          0x50, 0x1d, 0x02, 0x10, 0x17, 0xf1, 0x8f, 0xa7, 0x79, 0xbd, 0x3c, 0xff, 0xd9,
        ])

new TextDecoder().decode(uint8) // expect not to throw an error
@jimmywarting jimmywarting added the bug Issue was opened via the bug report template. label Oct 26, 2021
@jimmywarting jimmywarting changed the title TextDecoder is fatal TextDecoder seems to be incorrectly fatal=true by default? Oct 26, 2021
@jimmywarting
Copy link
Author

from the looks of your polyfilled source:

class TextDecoderRuntime {
decoder: TextDecoder
constructor() {
this.decoder = new TextDecoder()
}
get encoding() {
return this.decoder.encoding
}
get fatal() {
return this.decoder.fatal
}
get ignoreBOM() {
return this.decoder.ignoreBOM
}
public decode(input: BufferSource, options?: TextDecodeOptions) {
return this.decoder.decode(input, options)
}
}

it would seem to me that your version don't provide any valuable transformation or patching, so i'm wondering, why do you have a TextDecoderRuntime class? why bother having export { TextDecoderRuntime as TextDecoder }? it don't seem to bring any valuable stuff to the table

@javivelasco
Copy link
Member

I'm closing this one because I couldn't reproduce at all. The reason for the wrapper was to hide certain APIs / exposed a configured instance but I think it is not providing any value at the moment so I've opened #31490 to remove it. Still, I could not reproduce the issue so I'll close it directly.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. Middleware Related to Next.js Middleware
Projects
None yet
Development

No branches or pull requests

4 participants