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

New Vercel adapter generates conflicting lambda functions for routes with same filename but different directories #8401

Closed
1 task done
slawekkolodziej opened this issue Sep 4, 2023 · 0 comments
Labels
- P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority) feat: ssr Related to SSR (scope) pkg: vercel Related to Vercel adapter (scope)

Comments

@slawekkolodziej
Copy link
Contributor

slawekkolodziej commented Sep 4, 2023

Astro Info

Astro                    v3.0.8
Node                     v18.14.2
System                   macOS (arm64)
Package Manager          yarn
Output                   hybrid
Adapter                  @astrojs/vercel/serverless
Integrations             @astrojs/tailwind
                         @astrojs/svelte

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

No response

Describe the Bug

New version of vercel adapter can generate invalid output if two routes have the same file name, but different directory structure.

Consider the structure of pages directory below. In some lines I added vercel function names generated by the adapter:

├── index.astro      // -> entry.index.astro.func
├── 404.astro        // -> entry.404.astro.func
├── share
│   └── [id].astro   // -> entry._id_.astro.func
├── api
    ├── secrets.ts   // -> entry.secrets.astro.func
    └── secrets
        └── [id].ts  // -> entry._id_.astro.func <- this route produces the same vercel func name as share/[id].astro

For each page Vercel adapter is going to build a separate route handler. However, their names may conflict with each other, producing invalid output.

What's the expected result?

I would expect each route to produce separate lambda function.

I narrowed the problem down to this line in Vercel adapter:
https://github.com/withastro/astro/blob/main/packages/integrations/vercel/src/serverless/adapter.ts#L211

It generates function's directory name based on the file name only. I assume this will brake for every route with the same file names nested in different directories.

I can create PR soon.

Link to Minimal Reproducible Example

https://github.com/slawekkolodziej/secretsecret

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 Sep 4, 2023
@Princesseuh Princesseuh added - P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority) feat: ssr Related to SSR (scope) pkg: vercel Related to Vercel adapter (scope) and removed needs triage Issue needs to be triaged labels Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority) feat: ssr Related to SSR (scope) pkg: vercel Related to Vercel adapter (scope)
Projects
None yet
Development

No branches or pull requests

2 participants