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

HTMLRewriter eats exceptions #6124

Open
silversquirl opened this issue Sep 28, 2023 · 2 comments
Open

HTMLRewriter eats exceptions #6124

silversquirl opened this issue Sep 28, 2023 · 2 comments
Labels
bug Something isn't working HTMLRewriter cloudflare workers API

Comments

@silversquirl
Copy link
Contributor

What version of Bun is running?

1.0.3+25e69c71e70ac8a0a88f9cf15b4057bd7b2a633a

What platform is your computer?

Linux 6.4.15-200.fc38.x86_64 x86_64 unknown

What steps can reproduce the bug?

const rewriter = new HTMLRewriter().onDocument({
  text(text) {
    console.log(`processing text '${text.text}'`);
    throw new Error("error!");
    console.log("this is unreachable");
  },
});

const res = rewriter.transform(new Response("test"));
console.log(await res.text());

What is the expected behavior?

$ bun test.js
processing text 'test'
1 | const rewriter = new HTMLRewriter().onDocument({
2 |   text(text) {
3 |     console.log(`processing text '${text.text}'`);
4 |     throw new Error("error!");
              ^
error: error!
      at /var/home/silver/code/play/bun/test.js:4:10

What do you see instead?

$ bun test.js
processing text 'test'
processing text ''
test

Additional information

The exception does get thrown - as you can see, it cancels the rest of the handler - but it never makes it back out the other side of the transform call

@silversquirl silversquirl added the bug Something isn't working label Sep 28, 2023
@Electroid Electroid added the bun.js Something to do with a Bun-specific API label Sep 28, 2023
@infrahead
Copy link

duplicate of #3861 ?

@nektro nektro added HTMLRewriter cloudflare workers API and removed bun.js Something to do with a Bun-specific API labels Sep 13, 2024
@TomasHubelbauer
Copy link

I'm also facing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working HTMLRewriter cloudflare workers API
Projects
None yet
Development

No branches or pull requests

5 participants