Skip to content

[@astrojs/node] Server hangs in infinite loop if directory structure is not as expected. #14353

@Lattyware

Description

@Lattyware

Astro Info

Astro                    v5.13.7
Node                     v24.8.0
System                   Linux (x64)
Package Manager          npm
Output                   static
Adapter                  @astrojs/node
Integrations             @astrojs/react
                         generate-caddy-routes
                         prerendering-env-var

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

No response

Describe the Bug

I accidentally set up a docker image with only the built server code, and no client files. Unfortunately, rather than giving an error, this results in the server just hanging forever as it tries to find the path to the client files in an infinite loop.

This happens in resolveClientDir() where the assumption is made that walking up must eventually hit the server folder, but if you made the mistake I did and moved it out of that, it will result in an infinite loop as it just keeps trying to move up when it has already hit /.

For example, in my real world case

  0: serverEntryFolderURL = 'file:///app/chunks'
  1: serverFolder = 'server'

No matter how many times it walks up, that path is never going to end with server.

What's the expected result?

An error explaining that it can't find the client files, and what the directory structure was expected to be.

There should be a sanity check here to ensure there can't be an infinite loop, probably the safest option is checking that the value has actually changed, if it hasn't then the top of the directory structure has been reached and error out.

Link to Minimal Reproducible Example

Can't reporduce on StackBlitz as it's exposed by deployment process, but any build run without the directory structure will show it.

Participation

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P2: nice to haveNot breaking anything but nice to have (priority)pkg: nodeRelated to Node adapter (scope)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions