Skip to content

style tag is vanishing when doing async file IO in the site markup/JSX #17218

Description

@spaceemotion

Astro Info

Astro                    v7.0.3
Node                     v24.15.0
System                   Linux (x64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             @astrojs/markdoc
                         create-files

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

When doing any kind of heavier file IO operation inside of the HTML/JSX markup part of an .astro file, while Astro is doing something else in the background, style tags may disappear from the build output altogether.

This bug will not happen when you have a fast SSD and the files requires have already been cached or loaded into memory.

The minimal reproduction tries to make this problem happen deterministically by:

  1. Creating 10MB of random bits of data
  2. Requiring a content collection that loads in files (i checked, a standalone site does not work, it needs to have the markdoc files for some reason)
  3. Loads in the 10MB file via await inside of the JSX.

The temporary quick fix here is to move the file load call into the javascript part of the Astro file.

However, it's not intuitive or sometimes easy to spot that this is required. We only caught this by randomly spotting pages on our website missing specific styles, and reproducing this locally required us to find a machine with a slower/worse SSD. Needing to know where to put certain system-bound operations should not cause rendering to break in such a way.

What's the expected result?

The style tag should be inserted like normal and not dropped altogether, and any kind of File IO or system-bound operations should not affect the rendering.

Link to Minimal Reproducible Example

https://github.com/spaceemotion/astro-vanishing-style-on-file-io

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P4: importantViolate documented behavior or significantly impacts performance (priority)pkg: astroRelated to the core `astro` package (scope)triage: skippedCannot triage in CI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions