Skip to content

"../" being added to files when cwd has trailing slash on Node 23 #611

@nathanbedford

Description

@nathanbedford

Hi folks!

Just last night we started noticing an issue with glob on Heroku, where the 'files' array returned from glob has leading "../" characters, but only on Heroku (using Node 23) and only when the cwd has a trailing slash.

When using this:

glob("**/**", {
    cwd: "./static/",
    absolute: false,
    follow: true,
    nodir: true,
    dot: true,
  }

The output looks like this:

Example output

[
    "..",
    "../two.txt",
    "../one.txt"
],

It should look like this:

[
    ".",
    "two.txt",
    "one.txt"
  ]

Reproduction info

You can see the code I used here to reproduce this:
https://github.com/avodah-dev/glob-slash-weirdness/blob/main/index.js

Here's how it looks when deployed to Heroku, with the trailing slash on rootPath:
https://glob-test-aace9e4820c6.herokuapp.com/?s=1

And using the "s" query param here's how it looks without the trailing slash:
https://glob-test-aace9e4820c6.herokuapp.com/?s=0

Digital Ocean example (working correctly)

For reference, it works correctly when I run it locally or on Digital Ocean (app platform) using Node 22:
https://sea-turtle-app-vg7i8.ondigitalocean.app/?s=1

Background

We stumbled into this issue last week on Heroku, initially using a 3rd-party buildpack for pnpm, but then confirmed to be an issue using the official NodeJS buildpack, and using npm today.

It was working great yesterday morning on Heroku, but then started breaking on new builds last night (10/22/2024).

I'll create a support ticket with Heroku in case it's an issue completely on their end, but I was hoping glob maintainers might know what's going on too.

Updated

  • Added Node 23 distinction (Heroku just upgraded to use Node 23 while Digital Ocean is still using 22)
  • Added source code example

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions