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 does not respect fatal #3572

Closed
PotentialStyx opened this issue Jul 8, 2023 · 0 comments
Closed

TextDecoder does not respect fatal #3572

PotentialStyx opened this issue Jul 8, 2023 · 0 comments
Labels
bug Something isn't working web-api Something that relates to a standard Web API

Comments

@PotentialStyx
Copy link

PotentialStyx commented Jul 8, 2023

What version of Bun is running?

0.6.14

What platform is your computer?

Linux 5.15.90.1-microsoft-standard-WSL2 x86_64 unknown

What steps can reproduce the bug?

When creating a TextDecoder it can be configured to throw an error when it encounters invalid data like so:

const decoder = new TextDecoder("utf-8", { fatal: true });

However bun does not respect this, as seen with this code:

const decoder = new TextDecoder("utf-8", { fatal: true });
console.log(decoder.decode(new Uint8Array([195])));

What is the expected behavior?

The code should error when run, yet bun doesn't throw an error, and just returns a string.

In chrome the same code gives the following error:

VM28:2 Uncaught TypeError: Failed to execute 'decode' on 'TextDecoder': The encoded data was not valid.
    at <anonymous>:2:21
(anonymous) @ VM28:2

And in firefox:

Uncaught TypeError: TextDecoder.decode: Decoding failed.
    <anonymous> debugger eval code:1

What do you see instead?

Bun instead outputs:

Additional information

No response

@PotentialStyx PotentialStyx added the bug Something isn't working label Jul 8, 2023
@robobun robobun added the web-api Something that relates to a standard Web API label Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working web-api Something that relates to a standard Web API
Projects
None yet
Development

No branches or pull requests

2 participants