#template strings array (tag) function crashing bun

1 messages · Page 1 of 1 (latest)

plucky yacht
#

I use the html function from hono (https://hono.dev/middleware/builtin/html) and a vscode extension for syntax highlighting (https://marketplace.visualstudio.com/items?itemName=bierner.lit-html).

At some point, tag functions in bun stopped working in a certain case. I realized this after starting a new project + updating to latest version of canary.

Here is an example of the problem:

function test(value: TemplateStringsArray) {
    return new String(value)
}

// works
test`ok`
// @ts-ignore
test(`
    ok
`)

// below lines will crash bun
test`
    ok
`

Multi-line template literals in tag functions only work when enclosed in parenthesis. Is this intended behavior?

uh-oh: attempt to unwrap error
bun will crash now 😭😭😭

----- bun meta -----
Bun v0.6.8 (52d11ce8) Linux x64 #1 SMP Fri Apr 2 22:23:49 UTC 2021
AutoCommand:
Elapsed: 50ms | User: 21ms | Sys: 0ms
RSS: 33.55MB | Peak: 50.47MB | Commit: 33.55MB | Faults: 0
----- bun meta -----

0   0x555cd45aa45b

Crash report saved to:
  ~/.bun/.bun-crash/v0.6.8-1685921687534.crash

Search GitHub issues https://bun.sh/issues or ask for #help in https://bun.sh/discord

thread 2273 panic: attempt to unwrap error
Aborted

Ultrafast web framework for Cloudflare Workers, Fastly Compute@Edge, Deno, Bun, Vercel, Lagon, Node.js, and others. Fast, but not only fast.

#

this was functional around February in 0.5.7. i have no idea when it broke though

bitter aspen
#

interesting

#

I don't think this is the entire source of the error

#

can you paste a complete repro?

plucky yacht
#

it looks like it broke in 0.6.3 release

#

i can

bitter aspen
#

wow okay

#

i can reproduce that

#

will have a fix soon

plucky yacht
#

much appreciated, thanks!

plucky yacht
#

new development on my referenced repo

import { html } from "hono/html";

console.log(html`
    <head>
        <meta charset="UTF-8" />
        <title>${"meow123"}</title>
        <link rel="stylesheet" href="/css/style.css" />
    </head>
`)

expected output:

    <head>
        <meta charset="UTF-8" />
        <title>meow123</title>
        <link rel="stylesheet" href="/css/style.css" />
    </head>

canary output:

    <head>
        <meta charset="UTF-8" />
        <title>lmeow123</title>
        <link rel="stylesheet" href="/css/style.css" />
    </head>
>
bitter aspen
#

hm

bitter aspen
#

@fossil imp will take a look tomorrow

#

This code just needs tests really

#

I don’t think the \r\n normalization code had ever been run

fossil imp
#

have a fix for this, adding some tests