Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: possibleFilePath?.replace is not a function #10741

Closed
1 task
shishkin opened this issue Apr 10, 2024 · 7 comments · Fixed by #10745
Closed
1 task

TypeError: possibleFilePath?.replace is not a function #10741

shishkin opened this issue Apr 10, 2024 · 7 comments · Fixed by #10745
Labels
needs repro Issue needs a reproduction

Comments

@shishkin
Copy link
Contributor

Astro Info

Astro                    v4.5.18
Node                     v20.11.1
System                   macOS (arm64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/node
Integrations             @astrojs/tailwind
                         @astrojs/vue
                         astro-auth
                         @astrojs/react
                         @sentry/astro

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

No response

Describe the Bug

I get the following error when building on CI server:

12:39:27 [ERROR] [vite] x Build failed in 11.04s
TypeError: possibleFilePath?.replace is not a function
    at collectInfoFromStacktrace (file:///app/node_modules/astro/dist/core/errors/dev/utils.js:109:38)
    at file:///app/node_modules/astro/dist/core/errors/dev/utils.js:17:25
    at Array.forEach (<anonymous>)
    at collectErrorMetadata (file:///app/node_modules/astro/dist/core/errors/dev/utils.js:15:7)
    at throwAndExit (file:///app/node_modules/astro/dist/cli/throw-and-exit.js:16:29)
    at cli (file:///app/node_modules/astro/dist/cli/index.js:172:11)

Unfortunately, I can't reproduce it locally or on stackblitz. It actually masks another error I'm debugging. However, looking at the code, I see a potential mistake that the second replace is not called defensively:

const source = possibleFilePath?.replace(/^[^(]+\(([^)]+).*$/, '$1').replace(/^\s+at\s+/, '');

In any case, collectInfoFromStacktrace function is not robust against potentially missing data.

What's the expected result?

Astro's error handling should be robust. Showing raw error is always better than masking the error with own failure.

Link to Minimal Reproducible Example

N/A

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Apr 10, 2024
@lilnasy lilnasy added the needs repro Issue needs a reproduction label Apr 10, 2024
Copy link
Contributor

Hello @shishkin. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro will be closed if they have no activity within 3 days.

@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Apr 10, 2024
@lilnasy
Copy link
Contributor

lilnasy commented Apr 10, 2024

The change you've identified seems reasonable. Although, ideally we would be able to recreate the error before correcting it.

Could you share what CI server this occurs on alongside a small project? Is it running a non-Node runtime?

@shishkin
Copy link
Contributor Author

That's the problem - I can't reproduce the error anywhere else except the on-prem GitLab CI runner. It's a proxmox container on a x86_64 machine. Runtime is Node 20. And because astro is failing on the error handling I don't see what the real error is. The change that triggered the error was a release configuration in sentry integration. Probably it fails inside its vite plugin.

@lilnasy
Copy link
Contributor

lilnasy commented Apr 10, 2024

Could you run another build with experimental--10745 as the astro version instead of 4.5.18.

@HananoshikaYomaru
Copy link

I got this bug too, this lead to build fails on vercel. my astro version 4.5.16

@lilnasy
Copy link
Contributor

lilnasy commented Apr 10, 2024

@HananoshikaYomaru do you see the real error after deploying with astro@experimental--10745?

@shishkin
Copy link
Contributor Author

@lilnasy thanks for the quick response. I can confirm that astro@experimental--10745 displays the real error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Issue needs a reproduction
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants