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

[@astrojs/sitemap] Cannot add static source correctly using vercel on Astro 5 #12663

Open
1 task
cworld1 opened this issue Dec 6, 2024 · 7 comments
Open
1 task
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) pkg: vercel Related to Vercel adapter (scope)

Comments

@cworld1
Copy link

cworld1 commented Dec 6, 2024

Astro Info

Astro                    v5.0.3
Node                     v23.3.0
System                   Windows (x64)
Package Manager          pnpm
Output                   server
Adapter                  @astrojs/vercel
Integrations             @astrojs/mdx
                         @astrojs/sitemap

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

Firefox

Describe the Bug

This seems only take place in Astro v5.x. The log shows me files are created successfully to Vercel dist directory. But It doesn't show on Vercel static list.

image

Vercel build log:
[16:24:13.790] Running build in Washington, D.C., USA (East) – iad1
[16:24:13.928] Cloning github.com/cworld1/astro-blog-test (Branch: main, Commit: e6c2a7c)
[16:24:13.969] Skipping build cache, deployment was triggered without cache.
[16:24:14.248] Cloning completed: 319.937ms
[16:24:14.653] Running "vercel build"
[16:24:15.530] Vercel CLI 39.1.3
[16:24:16.653] Detected `pnpm-lock.yaml` version 9 generated by [email protected]
[16:24:16.670] Installing dependencies...
[16:24:17.483] Lockfile is up to date, resolution step is skipped
[16:24:17.559] Progress: resolved 1, reused 0, downloaded 0, added 0
[16:24:17.653] Packages: +391
[16:24:17.654] ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[16:24:18.560] Progress: resolved 391, reused 0, downloaded 56, added 43
[16:24:19.560] Progress: resolved 391, reused 0, downloaded 174, added 166
[16:24:20.568] Progress: resolved 391, reused 0, downloaded 276, added 265
[16:24:21.568] Progress: resolved 391, reused 0, downloaded 336, added 322
[16:24:21.833] Progress: resolved 391, reused 0, downloaded 391, added 391, done
[16:24:22.014] .../[email protected]/node_modules/esbuild postinstall$ node install.js
[16:24:22.016] .../[email protected]/node_modules/esbuild postinstall$ node install.js
[16:24:22.018] .../[email protected]/node_modules/sharp install$ node install/check
[16:24:22.192] .../[email protected]/node_modules/esbuild postinstall: Done
[16:24:22.202] .../[email protected]/node_modules/esbuild postinstall: Done
[16:24:22.250] .../[email protected]/node_modules/sharp install: Done
[16:24:22.366] 
[16:24:22.366] dependencies:
[16:24:22.367] + @astrojs/mdx 4.0.1
[16:24:22.367] + @astrojs/rss 4.0.10
[16:24:22.367] + @astrojs/sitemap 3.2.1
[16:24:22.367] + @astrojs/vercel 8.0.0
[16:24:22.367] + astro 5.0.3
[16:24:22.367] 
[16:24:22.373] Done in 5.4s
[16:24:22.411] Running "pnpm run build"
[16:24:22.918] 
[16:24:22.918] > [email protected] build /vercel/path0
[16:24:22.918] > astro build
[16:24:22.918] 
[16:24:24.793] 08:24:24 [content] Syncing content
[16:24:24.793] 08:24:24 [content] Content config changed
[16:24:24.793] 08:24:24 [content] Astro version changed
[16:24:24.793] 08:24:24 [content] Clearing content store
[16:24:25.385] 08:24:25 [content] Synced content
[16:24:25.387] 08:24:25 [types] Generated 1.34s
[16:24:25.402] 08:24:25 [build] output: "server"
[16:24:25.403] 08:24:25 [build] directory: /vercel/path0/dist/
[16:24:25.403] 08:24:25 [build] adapter: @astrojs/vercel
[16:24:25.403] 08:24:25 [build] Collecting build info...
[16:24:25.403] 08:24:25 [build] ✓ Completed in 1.38s.
[16:24:25.412] 08:24:25 [build] Building server entrypoints...
[16:24:27.084] 08:24:27 [WARN] [router] getStaticPaths() ignored in dynamic page /src/pages/blog/[...slug].astro. Add `export const prerender = true;` to prerender the page as static HTML during the build process.
[16:24:28.872] 08:24:28 [vite] �[32m✓ built in 3.40s�[39m
[16:24:28.873] 08:24:28 [build] ✓ Completed in 3.46s.
[16:24:28.895] 
[16:24:28.896]  prerendering static routes 
[16:24:28.896] 08:24:28 ✓ Completed in 10ms.
[16:24:28.897] 
[16:24:28.897] 08:24:28 [build] Rearranging server assets...
[16:24:28.910] 08:24:28 [@astrojs/vercel] Bundling function ../../../../dist/server/entry.mjs
[16:24:30.033] 08:24:30 [@astrojs/sitemap] `sitemap-index.xml` created at `dist/client`
[16:24:30.033] 08:24:30 [build] Server built in 6.02s
[16:24:30.033] 08:24:30 [build] Complete!
[16:24:30.114] Build Completed in /vercel/output [14s]
[16:24:30.162] Deploying outputs...
[16:24:33.838] 
[16:24:34.123] Deployment completed
[16:24:40.911] Uploading build cache [32.72 MB]...
[16:24:41.399] Build cache uploaded: 487.895ms

While local deployment looks good instead.

Local build log:
pnpm build

> [email protected] build D:\code\test\astro-blog-test
> astro build

16:33:26 [content] Syncing content
16:33:26 [content] Content config changed
16:33:26 [content] Astro version changed
16:33:26 [content] Clearing content store
16:33:27 [content] Synced content
16:33:27 [types] Generated 1.17s
16:33:27 [build] output: "server"
16:33:27 [build] directory: D:\code\test\astro-blog-test\dist\
16:33:27 [build] adapter: @astrojs/vercel
16:33:27 [build] Collecting build info...
16:33:27 [build] ✓ Completed in 1.23s.
16:33:27 [build] Building server entrypoints...
16:33:28 [WARN] [router] getStaticPaths() ignored in dynamic page /src/pages/blog/[...slug].astro. Add `export const prerender = true;` to prerender the page as static HTML during the build process.
16:33:29 [vite] ✓ built in 2.36s
16:33:29 [build] ✓ Completed in 2.40s.

 prerendering static routes
16:33:29 ✓ Completed in 20ms.

16:33:29 [build] Rearranging server assets...
16:33:29 [WARN] [@astrojs/vercel]
        The local Node.js version (23) is not supported by Vercel Serverless Functions.
        Your project will use Node.js 18 as the runtime instead.
        Consider switching your local version to 18.

16:33:29 [@astrojs/vercel] Bundling function ..\..\..\..\dist\server\entry.mjs
16:33:32 [@astrojs/sitemap] `sitemap-index.xml` created at `dist\client`
16:33:32 [build] Server built in 6.60s
16:33:32 [build] Complete!

image

What's the expected result?

https://astro-theme-pure.vercel.app/sitemap-index.xml

Link to Minimal Reproducible Example

https://github.com/cworld1/astro-blog-test

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 Dec 6, 2024
@cworld1
Copy link
Author

cworld1 commented Dec 6, 2024

By the way, this problem happened on using package findpage like starlight:

import { spawn } from 'node:child_process'
import { dirname, relative } from 'node:path'
import { fileURLToPath } from 'node:url'
import type { AstroIntegration } from 'astro'

export function pagefindConfig(): AstroIntegration {
  return {
    name: 'pagefind',
    hooks: {
      'astro:build:done': ({ dir }) => {
        const targetDir = fileURLToPath(dir)
        const cwd = dirname(fileURLToPath(import.meta.url))
        const relativeDir = relative(cwd, targetDir)

        return new Promise<void>((resolve) => {
          spawn('npx', ['-y', 'pagefind', '--site', relativeDir], {
            stdio: 'inherit',
            shell: true,
            cwd
          }).on('close', () => resolve())
        })
      }
    }
  }
}

(Starlight using Astro v4, where its pagefind module works well on Vercel, but same deploy code on Astro 5 simple template, it has the same problem like this issue)

@kevinwcyu
Copy link

I posted a comment on the PR where I think this was introduced. Currently I'm just working around it by patching this line

settings.config.integrations.unshift(settings.config.adapter);
to change it from unshift to push.

@cworld1
Copy link
Author

cworld1 commented Dec 9, 2024

@kevinwcyu Can I understand that this is caused by the removal of hydrid?

In addition, due to the busy life, I don't have much plan to read the Astro source code, but if you think this is a more correct solution, I think directly submitting the pr to Astro official repository may be a good choice.

After all, I want to be able to use Astro v5 in production as soon as possible, rather than letting these functions work wrong to the greatest extent, especially since I already created a lot of development code based on the branch base of Astro v5.

@Princesseuh
Copy link
Member

Interesting! Apologies for the regression, as I noted in my comment on the PR, I knew it could be consequential, but didn't know what it would actually do.

I'm not sure what the immediate solution is, as noted I did change the order for a reason, ha. We'll investigate

@Princesseuh Princesseuh added - P4: important Violate documented behavior or significantly impacts performance (priority) pkg: vercel Related to Vercel adapter (scope) and removed needs triage Issue needs to be triaged labels Dec 9, 2024
@cworld1
Copy link
Author

cworld1 commented Dec 9, 2024

@Princesseuh Thank you so much for your reply! I think the problem may actually be more due to not enough testing before this stable version is released, but I guess it doesn't matter if it is reported enough quick! Astro is still the coolest content-driven website framework in my mind, and I will be patient, waiting for your fix! If you need any other details about this problem, please don't hesitate to leave messages here!

@Princesseuh
Copy link
Member

Yeah, the beta has been up for multiple months now, but we'll always miss some edge cases like these. It happens! Hope we can fix this quickly.

hartmut-co-uk added a commit to thriving-dev/kafka-streams-topology-design that referenced this issue Jan 6, 2025
…yment error

- sitemaps not available
- search (pagefind) is not working
- gh issues:
  - withastro/adapters#445
  - withastro/astro#12663
  - arcjet/arcjet-docs#332
@Jpac14
Copy link

Jpac14 commented Jan 10, 2025

Any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) pkg: vercel Related to Vercel adapter (scope)
Projects
None yet
Development

No branches or pull requests

4 participants