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 crashes when an error is thrown in text #16357

Closed
TomasHubelbauer opened this issue Jan 12, 2025 · 0 comments · Fixed by #16368
Closed

HTMLRewriter crashes when an error is thrown in text #16357

TomasHubelbauer opened this issue Jan 12, 2025 · 0 comments · Fixed by #16368
Labels
crash An issue that could cause a crash macOS An issue that occurs on macOS runtime

Comments

@TomasHubelbauer
Copy link

How can we reproduce the crash?

const text = await response.text();
const htmlRewriter = new HTMLRewriter();

htmlRewriter.on('script[id="__NEXT_DATA__"]', {
  async text(text) {
    const data = JSON.parse(text.text);
    …
  },
});

Relevant log output

Bun v1.1.43-canary.11+5e003dccd (macOS arm64)
error: script exited with code 1

|   htmlRewriter.on('script[id="__NEXT_DATA__"]', {
|     async text(text) {
|       const data = JSON.parse(text.text);
                             ^
SyntaxError: JSON Parse error: Unterminated string
============================================================
Bun Canary v1.1.43-canary.11 (5e003dcc) macOS Silicon
macOS v15.1.1
Features: fetch html_rewriter jsc tsconfig 
Builtins: "bun:main" 

panic(main thread): Segmentation fault at address 0x10
oh no: Bun has crashed. This indicates a bug in Bun, not your code.

error: script was terminated by signal SIGTRAP (Trace or breakpoint trap)

Stack Trace (bun.report)

Bun v1.1.43-canary (5e003dc) on macos aarch64 [AutoCommand]

Segmentation fault at address 0x00000010

  • 1 unknown/js code
  • core::ptr::drop_in_place$LT$lol_html..rewriter..HtmlRewriter$LT$lolhtml..rewriter..ExternOutputSink$GT$$GT$::h16dd3e1853ee585e
  • lol_html_rewriter_free
  • src.bun.js.api.html_rewriter.HTMLRewriter.BufferOutputSink.deinit
  • src.bun.js.api.html_rewriter.HTMLRewriter.beginTransform
  • HTMLRewriterPrototype__transform
  • WebCore::HTMLRewriterPrototype__transformCallback
  • 1 unknown/js code
  • jsc_llint_commonCallOp__llintOpWithMetadata__llintOpWithReturn__llintOp__commonOp__fn__fn__makeReturn__fn__fn__fn__666_callHelper__dispatch_LowLevelInterpreter64_asm_2538
  • llint_call_javascript

Features: fetch, html_rewriter, jsc, tsconfig, tsconfig

Sentry Issue: BUN-B4D

@TomasHubelbauer TomasHubelbauer added the crash An issue that could cause a crash label Jan 12, 2025
@github-actions github-actions bot added macOS An issue that occurs on macOS runtime labels Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash An issue that could cause a crash macOS An issue that occurs on macOS runtime
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant