Skip to content

Dev server keeps the source <link rel="stylesheet"> tag after a failed CSS root recovers #40081

Closed as not planned

Description

@robobun

What version of Bun is running?

1.4.1 (canary, abe2ad4), debug build on Linux x64.

What steps will reproduce the bug?

Serve an HTML file that links a stylesheet through the dev server (the test/bake harness, BUN_FEATURE_FLAG_EXPERIMENTAL_BAKE=1):

<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="styles.css">
  </head>
  <body>hello</body>
</html>
  1. With styles.css = body { color: red; }, fetch /. The head is rewritten as expected:
    <head>\n \n <link rel="stylesheet" href="/_bun/asset/0d61081dd500b664.css"></head>
  2. Write styles.css = body { color: red; }} (a syntax error). Fetch /: the build error page, status 500. Expected.
  3. Write styles.css = body { color: green; }. Fetch /.

The same happens when the stylesheet has the syntax error from the start and is then fixed, and the extra tag stays on every later edit.

What is the expected behavior?

The head contains only the bundled link, as in step 1:

<head>
    
  <link rel="stylesheet" href="/_bun/asset/0d61081dd500b664.css"></head>

What do you see instead?

The source link tag is back, next to the bundled one:

<head>
    <link rel="stylesheet" href="styles.css">
  <link rel="stylesheet" href="/_bun/asset/0d61081dd500b664.css"></head>

A browser then requests /styles.css, which the HTML route answers with the HTML fallback (status 200, text/html), so the browser logs a MIME type error for that stylesheet. The route that recovers from a failure takes a different path than the first build and does not strip the source link tags.

Additional information

Found while tightening the assertions in test/bake/dev/css.test.ts. The test helper there reads only the /_bun/asset/ links for now.

Activity

  1. added
    bug
    bake:dev
    on Aug 22, 2026
  2. robobun commented on Aug 22, 2026

    @robobun
    CollaboratorAuthor

    Reproduced: after a parse-failed CSS root recovers, the dev server reuses HTML stored during the failed build, which keeps the source link tag.
    Fix in progress: #40092

  3. Jarred-Sumner commented on Oct 8, 2026

    @Jarred-Sumner
    Collaborator

    Use handoff tool. GitHub issues are for user-facing issues and a user did not run into this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bake:devbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions