Skip to content

HTMLRewriter crashes if calling before() without arguments #21680

@mGranTY

Description

@mGranTY

How can we reproduce the crash?

this crashes

const a = await fetch("https://loja.navesa.com.br/lateral-interna-do-paralama-dianteiro-esquerdo-para-renault-sandero-2014-ate-2023-cod-638313232r?_pid=xsbbc")
const rewriter = new HTMLRewriter().on("script", {
    element(a) {
    console.log(a.before())
    },
});
rewriter.transform(a)

this does not

const a = await fetch("https://loja.navesa.com.br/lateral-interna-do-paralama-dianteiro-esquerdo-para-renault-sandero-2014-ate-2023-cod-638313232r?_pid=xsbbc")
const rewriter = new HTMLRewriter().on("script", {
    element(a) {
    console.log(a.before("b"))
    },
});
rewriter.transform(a)

Relevant log output

Stack Trace (bun.report)

Bun v1.2.19 (aad3abe) on linux x86_64 [RunCommand]

panic: unreachable

Features: transpiler_cache, tsconfig, dotenv, fetch, html_rewriter, http_server, jsc

Metadata

Metadata

Assignees

No one assigned

    Labels

    HTMLRewritercloudflare workers APIassertion failedCrashes in a build with assertions enabledconfirmed bugWe can reproduce this issuecrashAn issue that could cause a crashlinuxAn issue that occurs on Linuxruntime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions