Coder Social home page Coder Social logo

adapters's People

Contributors

airborne04 avatar alexanderniebuhr avatar astrobot-houston avatar bholmesdev avatar bluwy avatar dario-piotrowicz avatar delucis avatar eliancodes avatar ematipico avatar fredkschott avatar fryuni avatar github-actions[bot] avatar himerus avatar hippotastic avatar isaac-mcfadyen avatar joshuakgoldberg avatar lilnasy avatar lorenzolewis avatar matthewp avatar mrienstra avatar natemoo-re avatar nrgnrg avatar okikio avatar princesseuh avatar richicoder1 avatar sarah11918 avatar sarahetter avatar schummar avatar skn0tt avatar yanthomasdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adapters's Issues

Netlify:`Astro.clientAddress` is not available

Astro Info

Astro                    v4.2.6
Node                     v18.18.2
System                   macOS (arm64)
Package Manager          npm
Output                   hybrid
Adapter                  @astrojs/netlify (latest version 5.0)
Integrations             @astrojs/mdx
                         @astrojs/sitemap
                         @astrojs/solid-js
                         @astrojs/tailwind

Describe the Bug

I tried using the clientAddress but the logs say it isn't available in the Netlify adapter

12:40:40 AM: 🚨 Could not enable emoji reactions for "enabling-emoji-post-reactions. Reason:"
12:40:40 AM: ClientAddressNotAvailable: `Astro.clientAddress` is not available in the `@astrojs/netlify` adapter. File an issue with the adapter to add support.
12:40:40 AM:     at get clientAddress [as clientAddress] (file:///opt/build/repo/node_modules/astro/dist/core/render/result.js:119:21)
12:40:40 AM:     at file:///opt/build/repo/.netlify/functions-internal/ssr/chunks/prerender_llcG8PKz.mjs:341:12
12:40:40 AM:     at AstroComponentInstance.EmojiReactions [as factory] (file:///opt/build/repo/.netlify/functions-internal/ssr/chunks/astro_uODeDaI0.mjs:219:12)
12:40:40 AM:     at AstroComponentInstance.init (file:///opt/build/repo/.netlify/functions-internal/ssr/chunks/astro_uODeDaI0.mjs:1038:29)
12:40:40 AM:     at AstroComponentInstance.render (file:///opt/build/repo/.netlify/functions-internal/ssr/chunks/astro_uODeDaI0.mjs:1043:18)
12:40:40 AM:     at Object.render (file:///opt/build/repo/.netlify/functions-internal/ssr/chunks/astro_uODeDaI0.mjs:1507:22)
12:40:40 AM:     at renderChild (file:///opt/build/repo/.netlify/functions-internal/ssr/chunks/astro_uODeDaI0.mjs:994:17) {
12:40:40 AM:   loc: undefined,
12:40:40 AM:   title: "`Astro.clientAddress` is not available in current adapter.",
12:40:40 AM:   hint: undefined,
12:40:40 AM:   frame: undefined,
12:40:40 AM:   type: "AstroError"
12:40:40 AM: }

What's the expected result?

I should be able to get the user's IP

Link to Minimal Reproducible Example

Here you can see what I tried EddyVinck/astro-engineering-blog@5827c40

Participation

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

WebSocket / WebSocketPair not available

Astro Info

Astro                    v4.2.6
Node                     v18.17.0
System                   macOS (arm64)
Package Manager          unknown
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             @astrojs/tailwind
                         @astrojs/react

Describe the Bug

I'm running astro with the Cloudflare adapter, and everything is working great apart from the WebSocket and WebSocketPair classes not being available in the server runtime.

export default defineConfig({
  // Mimics the behavior of Wrangler running locally so we don't have to alter the Cloudflare Tunnels
  server: {
    host: true,
    port: 8788,
  },
  // Server output is required for Cloudflare Workers
  output: "server",
  adapter: cloudflare({
    runtime: {
      mode: "local",
      type: "pages",
      bindings: { ... },
   }
  })
})

Local mode says: uses a local runtime powered by miniflare and workerd, which supports Cloudflare’s Bindings.. I might have missed the point here, but I was hoping that those classes would be available since they are on miniflare / workderd?

What's the expected result?

Works just like Cloudflare (as the declarations are available via:

/// <reference types="@cloudflare/workers-types" />

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-8ghpcm?file=src%2Fpages%2Findex.ts

Participation

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

`<Code>` component Fail to Build after Upgrading to Astro v4 and Cloudflare Adapter v8.0.0

Astro Info

Astro                    v4.0.6
Node                     v20.9.0
System                   macOS (x64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             @sanity/astro

Describe the Bug

Build fails at the stage "finalizing server assets" with the following error if I use the <Code> build-in component from astro:components

> [email protected] build
> astro build

07:28:52 [build] output: "server"
07:28:52 [build] directory: /workspaces/workspace/dist/
07:28:52 [build] adapter: @astrojs/cloudflare
07:28:52 [build] Collecting build info...
07:28:52 [build] βœ“ Completed in 59ms.
07:28:52 [build] Building server entrypoints...
07:28:54 [build] βœ“ Completed in 1.82s.
07:28:54 
 finalizing server assets 

07:28:54 [build] Rearranging server assets...
✘ [ERROR] Could not resolve "node:url"

    node_modules/@astrojs/markdown-remark/dist/load-plugins.js:3:30:
      3 β”‚ import { pathToFileURL } from "node:url";
        β•΅                               ~~~~~~~~~~

  The package "node:url" wasn't found on the file system but is built into
  node. Are you trying to bundle for node? You can use "platform: 'node'" to
  do that, which will remove this error.

✘ [ERROR] Could not resolve "node:fs"

    node_modules/import-meta-resolve/lib/resolve.js:11:44:
      11 β”‚ import {Stats, statSync, realpathSync} from 'node:fs'
         β•΅                                             ~~~~~~~~~

  The package "node:fs" wasn't found on the file system but is built into
  node. Are you trying to bundle for node? You can use "platform: 'node'" to
  do that, which will remove this error.

✘ [ERROR] Could not resolve "node:url"

    node_modules/import-meta-resolve/lib/resolve.js:13:48:
      13 β”‚ import {URL, fileURLToPath, pathToFileURL} from 'node:url'
         β•΅                                                 ~~~~~~~~~~

  The package "node:url" wasn't found on the file system but is built into
  node. Are you trying to bundle for node? You can use "platform: 'node'" to
  do that, which will remove this error.

✘ [ERROR] Could not resolve "node:module"

    node_modules/import-meta-resolve/lib/resolve.js:15:29:
      15 β”‚ import {builtinModules} from 'node:module'
         β•΅                              ~~~~~~~~~~~~~

  The package "node:module" wasn't found on the file system but is built into
  node. Are you trying to bundle for node? You can use "platform: 'node'" to
  do that, which will remove this error.

✘ [ERROR] Could not resolve "node:url"

    node_modules/import-meta-resolve/lib/get-format.js:5:28:
      5 β”‚ import {fileURLToPath} from 'node:url'
        β•΅                             ~~~~~~~~~~

  The package "node:url" wasn't found on the file system but is built into
  node. Are you trying to bundle for node? You can use "platform: 'node'" to
  do that, which will remove this error.

✘ [ERROR] Could not resolve "node:v8"

    node_modules/import-meta-resolve/lib/errors.js:19:15:
      19 β”‚ import v8 from 'node:v8'
         β•΅                ~~~~~~~~~

  The package "node:v8" wasn't found on the file system but is built into
  node. Are you trying to bundle for node? You can use "platform: 'node'" to
  do that, which will remove this error.

✘ [ERROR] Could not resolve "node:url"

    node_modules/import-meta-resolve/lib/errors.js:23:18:
      23 β”‚ import {URL} from 'node:url'
         β•΅                   ~~~~~~~~~~

  The package "node:url" wasn't found on the file system but is built into
  node. Are you trying to bundle for node? You can use "platform: 'node'" to
  do that, which will remove this error.

✘ [ERROR] Could not resolve "node:url"

    node_modules/import-meta-resolve/lib/package-config.js:9:33:
      9 β”‚ import {URL, fileURLToPath} from 'node:url'
        β•΅                                  ~~~~~~~~~~

  The package "node:url" wasn't found on the file system but is built into
  node. Are you trying to bundle for node? You can use "platform: 'node'" to
  do that, which will remove this error.

✘ [ERROR] Could not resolve "node:fs"

    node_modules/import-meta-resolve/lib/package-json-reader.js:22:15:
      22 β”‚ import fs from 'node:fs'
         β•΅                ~~~~~~~~~

  The package "node:fs" wasn't found on the file system but is built into
  node. Are you trying to bundle for node? You can use "platform: 'node'" to
  do that, which will remove this error.

✘ [ERROR] Could not resolve "node:url"

    node_modules/import-meta-resolve/lib/package-json-reader.js:24:28:
      24 β”‚ import {fileURLToPath} from 'node:url'
         β•΅                             ~~~~~~~~~~

  The package "node:url" wasn't found on the file system but is built into
  node. Are you trying to bundle for node? You can use "platform: 'node'" to
  do that, which will remove this error.

Could not resolve "node:url"
  Stack trace:
    at failureErrorWithLog (/workspaces/workspace/node_modules/esbuild/lib/main.js:1650:15)
    at /workspaces/workspace/node_modules/esbuild/lib/main.js:1003:52
    at /workspaces/workspace/node_modules/esbuild/lib/main.js:1085:16
    at handleIncomingPacket (/workspaces/workspace/node_modules/esbuild/lib/main.js:763:9)
    at Socket.emit (node:events:514:28)

Note:

  • Build only fails when <Code> is used
  • Build works for the node adapter even with <Code>
  • Cloudflare Adapter version: 8.0.0

Thanks

What's the expected result?

The build should succeed.

Link to Minimal Reproducible Example

https://codesandbox.io/p/devbox/suspicious-wozniak-82gcxq

Participation

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

Netlify adapter suggests an incorrect link

Astro Info

Astro                    v4.0.7
Node                     v18.15.0
System                   macOS (arm64)
Package Manager          pnpm
Output                   static
Adapter                  @astrojs/netlify
Integrations             @astrojs/react
                         @astrojs/starlight

Describe the Bug

This bug

[AstroUserError] config.image.domains and config.image.remotePatterns aren't supported by the Netlify adapter.
  Hint:
    See https://github.com/withastro/adapters/tree/main/packages/netlify#image-cdn for more.
  Stack trace:

Points to an URL that doesn't exist in the README.md

What's the expected result?

It should point to https://github.com/withastro/adapters/tree/main/packages/netlify#netlify-image-cdn-support

Link to Minimal Reproducible Example

none

Participation

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

Astro Cloudflare - Failed to publish your Function. Got error: Error 8000057: Overlapping rules in `_routes.json` are not allowed.

Astro Info

Astro                    v4.2.1
Node                     v21.5.0
System                   macOS (arm64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             @storyblok/astro
                         @astrojs/preact
                         @astrojs/sitemap

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

No response

Describe the Bug

Hello, I'm developing an Astro website with static pages generated at the following paths:

  • /companies/index.astro
  • /companies/[slug].astro
  • /blog/index.astro
  • /blog/[slug].astro

Any other page is server-side rendered.

In order to avoid the _routes.json 100-entries limit error addressed in withastro/astro#6516, I'm manually excluding the static paths as described in the docs:

adapter: cloudflare({
   routes: {
      exclude: ['/companies/*', '/blog/*'],
   },
})

The redundant paths /companies/ and /blog/ are not stripped away from the generated _routes.json if I have set the following redirect in 404.astro:

---
return Astro.redirect('/', 301)
---

Causing the following deploy error (as /companies/* and /blog/* are also present in the _routes.json file):

Error: Failed to publish your Function. Got error: Error 8000057: Overlapping rules in `_routes.json` are not allowed. Rule "/companies/" is overlapped by "/companies/*". Remove one of the rules to continue.

Generated routes.json

{
  "version": 1,
  "include": [
    "/*"
  ],
  "exclude": [
    "/companies/",
    "/companies/*",
    "/blog/",
    "/blog/*",
    // ...
  ]
}

What's the expected result?

{
  "version": 1,
  "include": [
    "/*"
  ],
  "exclude": [
    "/companies/*",
    "/blog/*",
    // ...
  ]
}

Link to Minimal Reproducible Example

https://stackblitz.com/edit/withastro-astro-cykvsk?file=dist%2F_routes.json

Participation

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

explicit routes strategy overwritten by auto logic

Describe the Bug

When explicitly setting a routes strategy it is not always used, depending on other checks. However those checks should only be used in the auto strategy

What's the expected result?

Have all checks and protection for auto strategy, while allowing any custom strategy (with no checks & protections) if set explicitly by include or exclude strategy

Participation

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

When using Lit Element, CloudFlare function cannot be published because HTMLElement is not defined

Astro Info

Astro                    v4.1.3
Node                     v19.9.0
System                   macOS (x64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             @astrojs/lit

Describe the Bug

I am trying to deploy a project using Lit on Cloudflare Pages using the @astrojs/cloudflare adapter. Locally, everything is working fine, but when pushing to Cloudflare pages using the Cloudflare adapter, I get the following error message after a successful build:

Error: Failed to publish your Function. Got error: Uncaught ReferenceError: HTMLElement is not defined at functionsWorker-0.056383667617412536.js:1471:3

I get several messages further up the stacktrace that give me a warning:

Ambiguous external namespace resolution: "node_modules/.pnpm/[email protected]/node_modules/lit/index.js" re-exports "html" from one of the external modules "lit-element/lit-element.js" and "lit-html/is-server.js", guessing "lit-element/lit-element.js".****

This makes me worried that the DOM-shim provided by the @lit-labs/ssr is not being included in the bundle. Is it possible to fix this ambiguous namespace, or a direct way to load the DOM shim so HTMLElement is recognized in the Cloudflare Function?

the astro.config.mjs:

import { defineConfig } from 'astro/config';
import lit from "@astrojs/lit";
import cloudflare from "@astrojs/cloudflare";

// https://astro.build/config
// @see https://developers.cloudflare.com/pages/framework-guides/deploy-an-astro-site/#modes
export default defineConfig({
 integrations: [lit()],
 output: "server", // both outputs give same error
 adapter: cloudflare({mode: 'directory'}) // both modes give same error
});

the package.json:

{
 "main": "index.js",
 "scripts": {
   "dev": "astro dev",
   "start": "astro dev",
   "build": "astro build",
   "preview": "astro preview"
 },
 "keywords": [],
 "author": "",
 "license": "ISC",
 "dependencies": {
   "@astrojs/cloudflare": "^8.1.0",
   "@astrojs/lit": "^4.0.1",
   "@astrojs/mdx": "^2.0.4",
   "@lit-labs/ssr": "^3.2.1",
   "@lit-labs/ssr-dom-shim": "^1.1.2",
   "@webcomponents/template-shadowroot": "^0.2.1",
   "astro": "^4.1.3",
   "lit": "^3.1.1",
   "open-props": "^1.6.17",
   "@cloudflare/workers-types": "^4.20240117.0",
 }
}

I found these related issues + PRs:

Here is the more complete stacktrace from the Cloudflare console:

10:40:10.637 | Ambiguous external namespace resolution: "node_modules/.pnpm/[email protected]/node_modules/lit/index.js" re-exports "css" from one of the external modules "lit-element/lit-element.js" and "lit-html/is-server.js", guessing "lit-element/lit-element.js".
-- | --
10:40:10.638 | Ambiguous external namespace resolution: "node_modules/.pnpm/[email protected]/node_modules/lit/index.js" re-exports "html" from one of the external modules "lit-element/lit-element.js" and "lit-html/is-server.js", guessing "lit-element/lit-element.js".
10:40:10.639 | Ambiguous external namespace resolution: "node_modules/.pnpm/[email protected]/node_modules/lit/index.js" re-exports "LitElement" from one of the external modules "lit-element/lit-element.js" and "lit-html/is-server.js", guessing "lit-element/lit-element.js".
10:40:10.886 | "css", "html" and "LitElement" are imported from external module "lit-html/is-server.js" but never used in "node_modules/.pnpm/[email protected]/node_modules/lit/index.js".
10:40:10.950 | 02:40:10 [build] βœ“ Completed in 1.05s.
10:40:10.950 | Β 
10:40:10.951 | building client (vite)
10:40:10.960 | 02:40:10 [vite] transforming...
10:40:11.063 | 02:40:11 [vite] βœ“ 33 modules transformed.
10:40:11.082 | 02:40:11 [vite] rendering chunks...
10:40:11.089 | 02:40:11 [vite] computing gzip size...
10:40:11.092 | 02:40:11 [vite] dist/_astro/directive.xgBC_cM0.js                          0.42 kB β”‚ gzip: 0.31 kB
10:40:11.093 | 02:40:11 [vite] dist/_astro/client.KliVgTTX.js                             0.62 kB β”‚ gzip: 0.39 kB
10:40:11.093 | 02:40:11 [vite] dist/_astro/HeaderNav.0BeSTiyq.js                          2.13 kB β”‚ gzip: 0.97 kB
10:40:11.093 | 02:40:11 [vite] dist/_astro/XCheckbox.y_7YmnQg.js                          2.89 kB β”‚ gzip: 1.38 kB
10:40:11.093 | 02:40:11 [vite] dist/_astro/astro_scripts/before-hydration.js.cW-K1qaT.js  5.64 kB β”‚ gzip: 2.36 kB
10:40:11.093 | 02:40:11 [vite] dist/_astro/lit-html.t5Xi0LsG.js                           7.17 kB β”‚ gzip: 3.16 kB
10:40:11.093 | 02:40:11 [vite] dist/_astro/custom-element.TrIwOAjq.js                     8.19 kB β”‚ gzip: 3.02 kB
10:40:11.094 | 02:40:11 [vite] βœ“ built in 138ms
10:40:11.142 | 02:40:11
10:40:11.142 | finalizing server assets
10:40:11.142 | Β 
10:40:11.143 | 02:40:11 [build] Rearranging server assets...
10:40:11.228 | 02:40:11 [build] Server built in 1.43s
10:40:11.228 | 02:40:11 [build] Complete!
10:40:11.271 | Finished
10:40:11.272 | Found Functions directory at /functions. Uploading.
10:40:12.554 | ✨ Compiled Worker successfully
10:40:12.584 | Found _routes.json in output directory. Uploading.
10:40:12.596 | Validating asset output directory
10:40:13.602 | Deploying your site to Cloudflare's global network...
10:40:18.373 | Uploading... (8/8)
10:40:18.374 | ✨ Success! Uploaded 0 files (8 already uploaded) (0.67 sec)
10:40:18.374 | Β 
10:40:18.868 | ✨ Upload complete!
10:40:21.562 | Success: Assets published!
10:40:22.626 | Error: Failed to publish your Function. Got error: Uncaught ReferenceError: HTMLElement is not defined   at functionsWorker-0.056383667617412536.js:1471:3   at functionsWorker-0.056383667617412536.js:7:38   at functionsWorker-0.056383667617412536.js:1968:3   at functionsWorker-0.056383667617412536.js:7:38   at functionsWorker-0.056383667617412536.js:7338:3   at functionsWorker-0.056383667617412536.js:7:38   at functionsWorker-0.056383667617412536.js:7428:3   at functionsWorker-0.056383667617412536.js:7:38   at functionsWorker-0.056383667617412536.js:7435:3   at functionsWorker-0.056383667617412536.js:7:38

What's the expected result?

I expected the Function to be able to be published after being built successfully. Everything local is working fine.

Link to Minimal Reproducible Example

https://github.com/dengel29/dngl

Participation

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

Astro Netlify adapter with on-demand builder not caching

What version of astro are you using?

2.8.3

Are you using an SSR adapter? If so, which one?

Netlify

What package manager are you using?

yarn

What operating system are you using?

Linux

What browser are you using?

Chromium

Describe the Bug

Reading the documentation it seems it is possible to use Netlify On-Demand builder to build pages on demand and then cache them on the Netlify CDN.

I tried to implement this feature but it doesn't seem to work.

Here is my code:

// astro.config.mjs

import { defineConfig } from 'astro/config';
import netlify from "@astrojs/netlify/functions";

// https://astro.build/config
export default defineConfig({
  output: "server",
  adapter: netlify({
    builders: true,
  })
});
# netlify.toml

[build]
  command = "yarn build"
  publish = "dist"
// src/pages/index.astro

---
import Layout from "../layouts/Layout.astro";

const response = await new Promise((resolve, reject) => {
  setTimeout(() => {
    resolve(7);
  }, 2000)
});
---

<Layout title="Welcome to Astro">
  <main>MAIN {response}</main>
</Layout>

The setTimeout is for emulating an async method that takes some time.

After deploying with:

ntl deploy --prod

I see the page waiting 2 seconds before delivering the HTML.

However I would expect the Netlify On-Demand Builder to cache it and then not wait 2 seconds anymore.

I checked on Netlify support and a Support Engineer answer with this:
https://answers.netlify.com/t/astro-adapter-with-on-demand-builder-not-caching/96756/4?u=ndr4

That site is not using On Demand Builders. It has a single redirect that’s redirecting to /.netlify/functions/entry. Paths at /.netlify/functions are not builder functions. This is an Astro issue. They need to redirect to /.netlify/builders.

Is this true? Is this a bug in the Astro Netlify adapter library?

What's the expected result?

When I call the URL the On-demand builder cache the response. The second time I call the same URL the CDN respond with the cached version.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-zfmbew?file=astro.config.mjs

Participation

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

External rewrites do not work on Netlify

Astro Info

Astro                    v4.2.4
Node                     v18.19.0
System                   Windows (x64)
Package Manager          yarn
Output                   hybrid
Adapter                  @astrojs/netlify
Integrations             @astrojs/mdx
                         @astrojs/sitemap

Describe the Bug

When having such a rewrite inside public/_redirects, it just does not work. It used to work in v3:

/test https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js 200!

See https://65b26bfaede6390008a7ac7a--splendid-youtiao-ce6c96.netlify.app/test

What's the expected result?

The rewrite should work, not return a 404.

Link to Minimal Reproducible Example

https://github.com/florian-lefebvre/astro-netlify-redirects-repro

Participation

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

Unable to start dev with Cloudflare adapter: `file already exists, mkdir './node_modules/.astro/'`

Astro Info

Astro                    v4.3.2
Node                     v21.6.1
System                   Linux (x64)
Package Manager          pnpm
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             @astrojs/tailwind
                         @astrojs/solid-js

Describe the Bug

Running pnpm dev stopped working, produces the following output (replaced absolute project path with '...')

10:31:45 [WARN] The currently selected adapter `@astrojs/cloudflare` is not compatible with the image service "Sharp".

 astro  v4.3.2 ready in 310 ms

┃ Local    http://localhost:4321/
┃ Network  use --host to expose

10:31:45 watching for file changes...
10:31:47 [ERROR] [UnhandledRejection] Astro detected an unhandled rejection. Here's the stack trace:
Error: EEXIST: file already exists, mkdir '/.../node_modules/.astro/'
    at mkdirSync (node:fs:1382:26)
    at LocalPagesRuntime.getCF (file:///.../node_modules/.pnpm/@[email protected][email protected]/node_modules/@astrojs/cloudflare/dist/utils/local-runtime.js:114:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async middleware (file:///.../node_modules/.pnpm/@[email protected][email protected]/node_modules/@astrojs/cloudflare/dist/index.js:67:36)
  Hint:
    Make sure your promises all have an `await` or a `.catch()` handler.
  Error reference:
    https://docs.astro.build/en/reference/errors/unhandled-rejection/
  Stack trace:
    at mkdirSync (node:fs:1382:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    [...] See full stack trace in the browser, or rerun with --verbose.

What's the expected result?

pnpm dev works

Workaround

Removing the directory fixes the problem permanently: rm -r node_modules/.astro/

Participation

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

Build Breaking Astro 4.0

  • update astro to 4.0
  • run pnpm run build
❯ pnpm --filter @astrojs/cloudflare run build

> @astrojs/[email protected] build /Users/alexanderniebuhr/Developer/Projects/withastro_adapters/packages/cloudflare
> tsc

src/index.ts:98:8 - error TS2322: Type 'Plugin_2' is not assignable to type 'PluginOption'.
  Type 'Plugin_2' is not assignable to type 'Plugin<any>'.
    Types of property 'apply' are incompatible.
      Type '"build" | "serve" | ((this: void, config: import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).UserConfig, env: import("/Users/alexanderniebuhr/Developer/Projects/withas...' is not assignable to type '"build" | "serve" | ((this: void, config: import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).UserConfig, env: import("/Users/alexanderniebuhr/Developer/Projects/withas...'.
        Type '(this: void, config: UserConfig, env: ConfigEnv) => boolean' is not assignable to type '"build" | "serve" | ((this: void, config: UserConfig, env: ConfigEnv) => boolean) | undefined'.
          Type '(this: void, config: import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).UserConfig, env: import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_mod...' is not assignable to type '(this: void, config: import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).UserConfig, env: import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_mod...'.
            Types of parameters 'config' and 'config' are incompatible.
              Type 'import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).UserConfig' is not assignable to type 'import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).UserConfig'.
                Types of property 'plugins' are incompatible.
                  Type 'import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).PluginOption[] | undefined' is not assignable to type 'import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).PluginOption[] | undefined'.
                    Type 'import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).PluginOption[]' is not assignable to type 'import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).PluginOption[]'.
                      Type 'import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).PluginOption' is not assignable to type 'import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).PluginOption'.
                        Type 'Plugin<any>' is not assignable to type 'PluginOption'.
                          Type 'Plugin<any>' is not assignable to type 'Plugin_2'.
                            Types of property 'apply' are incompatible.
                              Type '"build" | "serve" | ((this: void, config: import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).UserConfig, env: import("/Users/alexanderniebuhr/Developer/Projects/withas...' is not assignable to type '"build" | "serve" | ((this: void, config: import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).UserConfig, env: import("/Users/alexanderniebuhr/Developer/Projects/withas...'.
                                Type '(this: void, config: UserConfig, env: ConfigEnv) => boolean' is not assignable to type '"build" | "serve" | ((this: void, config: UserConfig, env: ConfigEnv) => boolean) | undefined'.
                                  Type '(this: void, config: import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).UserConfig, env: import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_mod...' is not assignable to type '(this: void, config: import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).UserConfig, env: import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_mod...'.
                                    Types of parameters 'config' and 'config' are incompatible.
                                      Type 'import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).UserConfig' is not assignable to type 'import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).UserConfig'.
                                        Types of property 'plugins' are incompatible.
                                          Type 'import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).PluginOption[] | undefined' is not assignable to type 'import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).PluginOption[] | undefined'.
                                            Type 'import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).PluginOption[]' is not assignable to type 'import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).PluginOption[]'.
                                              Type 'import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).PluginOption' is not assignable to type 'import("/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index", { assert: { "resolution-mode": "import" } }).PluginOption'.
                                                Type 'PluginOption[]' is not assignable to type 'PluginOption'.

 98        wasmModuleLoader({
           ~~~~~~~~~~~~~~~~~~
 99         disabled: !args?.wasmModuleImports,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
100         assetsDirectory: config.build.assets,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101        }),
    ~~~~~~~~~


Found 1 error in src/index.ts:98

/Users/alexanderniebuhr/Developer/Projects/withastro_adapters/packages/cloudflare:
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @astrojs/[email protected] build: `tsc`
Exit status 2

SSR routes 404 on Netlify when a non-competing static route uses rest parameter at the root

What version of astro are you using?

2.7.2

Are you using an SSR adapter? If so, which one?

Netlify 2.3.0

What package manager are you using?

npm

What operating system are you using?

Mac

What browser are you using?

Chrome

Describe the Bug

On a hybrid project, SSR routes systematically returns 404 on Netlify when a rest parameter is used at the root of the pages directory.

🚫

src/
β”œβ”€ pages/
β”‚  β”œβ”€ [...page].astro (static works)
β”‚  β”œβ”€ persons/[id].astro (ssr 404)

βœ…

src/
β”œβ”€ pages/
β”‚  β”œβ”€ [page].astro (static works)
β”‚  β”œβ”€ persons/[id].astro (ssr works)

This problem appears above @astro/netlify 2.2.0, downgrading to said version fixes the issue. Astro version seems irrelevant.

What's the expected result?

SSR routes should work on Netlify regardless of rest parameter dynamic static route at the root.

Link to Minimal Reproducible Example

https://github.com/regisphilibert/astro-issue-repro-netlify-ssr

Participation

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

Cloudflare adapter i18ndomains error with Astro 4.3

Astro Info

Astro                    v4.3.0
Node                     v20.10.0
System                   macOS (arm64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             @astrojs/react

Describe the Bug

The following errors occur on startup with the new Astro 4.3 i18nDomains feature

14:36:48 [ERROR] [config] The feature "i18nDomains" is not supported (used by @astrojs/cloudflare).
14:36:48 [ERROR] The adapter @astrojs/cloudflare doesn't support the feature i18nDomains. Your project won't be built. You should not use it.

What's the expected result?

A project not using i18nDomains should still work on the Cloudflare adapter

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-k3ev6s?file=astro.config.mjs

Participation

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

@astrojs/lit breaks @astrojs/cloudflare builds

What version of astro are you using?

2.3.0

Are you using an SSR adapter? If so, which one?

Cloudflare

What package manager are you using?

yarn

What operating system are you using?

Mac

What browser are you using?

Brave

Describe the Bug

When deploying via GitHub, the astro project builds successfully, but fails at deploying the CF function.

No lit components are used in the project; simply adding lit to the integrations field in the config seems to break deployments.

The error from Cloudflare:
Error: Failed to publish your Function. Got error: Uncaught ReferenceError: window is not defined at functionsWorker-xxxx.js:2140:10

A snippet of what could be the offending code in the build:

var ea = window,
  aa =
    ea.ShadowRoot &&
    (ea.ShadyCSS === void 0 || ea.ShadyCSS.nativeShadow) &&
    "adoptedStyleSheets" in Document.prototype &&
    "replace" in CSSStyleSheet.prototype,
  Fn = Symbol(),
  Sn = new WeakMap(),
  ta = class {
    constructor(t, a, u) {
      if (((this._$cssResult$ = !0), u !== Fn))
        throw Error(
          "CSSResult is not constructable. Use `unsafeCSS` or `css` instead.",
        );
      (this.cssText = t), (this.t = a);
    }
    get styleSheet() {
...

This is apparently from the Lit library itself.

I'll keep digging in to see what I can find out, but I'd greatly appreciated any help!

Link to Minimal Reproducible Example

https://github.com/chaffinated/astro-lit-cloudflare-repro

Participation

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

Netlify: Host fails to serve 404 page on failing routes when adapter is in use.

Astro Info

Astro                    v4.2.1
Node                     v21.1.0
System                   macOS (arm64)
Package Manager          npm
Output                   hybrid
Adapter                  @astrojs/netlify
Integrations             none

Describe the Bug

The 404 logic of Netlify is broken on a deployed hybrid project. Netlify fails to serve the 404 page (Netlify's or project's own 404.html). See: https://imaginative-pastelito-41792a.netlify.app/notfound

If one tries to enforce the 404 logic by manually adding a redirect rule:

# _redirect
/* /404.html 404

Then SSR routes (not static) will all land on the provided 404 file.

See https://imaginative-pastelito-41792a.netlify.app/ deployed from minimal repo.

What's the expected result?

When route is not found Netlify should serve its own 404 page or the project's own 404.html

Link to Minimal Reproducible Example

https://github.com/regisphilibert/astro-netlify-404-repro

Participation

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

Cloudflare build failed

Astro Info

Astro                    v4.0.2
Node                     v18.18.2
System                   macOS (x64)
Package Manager          pnpm
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             @astrojs/tailwind
                         @astrojs/solid-js

Describe the Bug

Build fails when generating server side assets. Astro set for ssr rendering.

10:01:32.919	 finalizing server assets 
10:01:32.919	
10:01:32.919	09:01:32 [build] Rearranging server assets...
10:01:33.000	✘ [ERROR] Could not resolve "events"
10:01:33.001	
10:01:33.001	    node_modules/.pnpm/[email protected]/node_modules/node-cache/lib/node_cache.js:18:25:
10:01:33.001	      18 β”‚   EventEmitter = require('events').EventEmitter;
10:01:33.002	         β•΅                          ~~~~~~~~
10:01:33.002	
10:01:33.002	  The package "events" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
10:01:33.002	
10:01:33.116	✘ [ERROR] Could not resolve "os"
10:01:33.116	
10:01:33.116	    dist/$server_build/chunks/pages/index_Zh0V2mBm.mjs:1:25:
10:01:33.116	      1 β”‚ import require$$0$4 from 'os';
10:01:33.117	        β•΅                          ~~~~
10:01:33.117	
10:01:33.117	  The package "os" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
10:01:33.117	
10:01:33.131	✘ [ERROR] Could not resolve "fs"
10:01:33.132	
10:01:33.132	    dist/$server_build/chunks/pages/index_Zh0V2mBm.mjs:2:7:
10:01:33.132	      2 β”‚ import 'fs';
10:01:33.132	        β•΅        ~~~~
10:01:33.132	
10:01:33.133	  The package "fs" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
10:01:33.133	
10:01:33.138	✘ [ERROR] Could not resolve "url"
10:01:33.138	
10:01:33.139	    dist/$server_build/chunks/pages/index_Zh0V2mBm.mjs:3:7:
10:01:33.139	      3 β”‚ import 'url';
10:01:33.139	        β•΅        ~~~~~
10:01:33.139	
10:01:33.139	  The package "url" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
10:01:33.139	
10:01:33.140	✘ [ERROR] Could not resolve "path"
10:01:33.140	
10:01:33.140	    dist/$server_build/chunks/pages/index_Zh0V2mBm.mjs:4:7:
10:01:33.140	      4 β”‚ import 'path';
10:01:33.140	        β•΅        ~~~~~~
10:01:33.140	
10:01:33.140	  The package "path" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
10:01:33.141	
10:01:33.602	Could not resolve "os"
10:01:33.603	  Stack trace:
10:01:33.603	    at failureErrorWithLog (/opt/buildhome/repo/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1650:15)
10:01:33.603	    at /opt/buildhome/repo/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1003:52
10:01:33.603	    at /opt/buildhome/repo/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1085:16
10:01:33.604	    at handleIncomingPacket (/opt/buildhome/repo/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:763:9)
10:01:33.604	    at Socket.emit (node:events:514:28)
10:01:33.604	    at readableAddChunk (node:internal/streams/readable:297:9)
10:01:33.604	    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)
10:01:33.637	npm notice 
10:01:33.638	npm notice New major version of npm available! 9.6.7 -> 10.2.5
10:01:33.638	npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.2.5>
10:01:33.638	npm notice Run `npm install -g [email protected]` to update!
10:01:33.639	npm notice 
10:01:33.649	Failed: Error while executing user command. Exited with error code: 1
10:01:33.658	Failed: build command exited with code: 1
10:01:34.623	Failed: error occurred while running build command

What's the expected result?

Build should not failed.

Link to Minimal Reproducible Example

ca

Participation

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

Cloudflare Hyperdrive

Astro Info

Astro                    v4.0.8
Node                     v20.10.0
System                   Linux (x64)
Package Manager          bun
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             unocss
                         @astrojs/solid-js
                         @swup/astro

Describe the Bug

Cloudflare Hyperdrive doesn't work either in production using Cloudflare Workers or locally (via the provided localConnectionString). When I try to read it in my endpoints as locals.runtime.env.HD.connectionString, HD is undefined and it throws an error.

wrangler.toml:

[[hyperdrive]]
binding = "HD"
id = "XXX" # Hyperdrive ID

astro.config.mjs:

{
  ...
  adapter: cloudflare({
    mode: 'advanced',
    functionPerRoute: false,
    runtime: {
      mode: 'local',
      type: 'pages',
      bindings: {
        'HD': {
          type: 'hyperdrive',
          id: 'XXX', # Hyperdrive ID
          localConnectionString: import.meta.env.DB_CONNECTION,
        }
      }
    }
  }),
  ...
}

env.d.ts:

/// <reference types="astro/client" />

type Hyperdrive = import("@cloudflare/workers-types").Hyperdrive
type ENV = {
  HD: Hyperdrive
}

type Runtime = import("@astrojs/cloudflare").AdvancedRuntime<ENV>
declare namespace App {
  interface Locals extends Runtime {
    ...
  }
}

What's the expected result?

It should work, at least when deployed.

Link to Minimal Reproducible Example

N/A

Participation

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

Typing Astro.locals for Cloudflare runtime

πŸ“š Subject area/topic

Cloudflare adapter

πŸ“‹ Page(s) affected (or suggested, for new content)

https://docs.astro.build/en/guides/integrations-guide/cloudflare/#access-to-the-cloudflare-runtime

πŸ“‹ General description or bullet points (if proposing new content)

The documentation on how to add proper typing for Astro.locals seems incorrect. As can be seen from the error produced by running astro check in the reproduction: error ts(2339): Property 'runtime' does not exist on type 'Locals'..

Using declare global instead, as in the code below, seems to work.

/// <reference types="astro/client" />
import type { AdvancedRuntime } from '@astrojs/cloudflare';

type ENV = {
  SERVER_URL: string;
};

declare global {
  namespace App {
    interface Locals extends AdvancedRuntime<ENV> {
      user: {
        name: string;
        surname: string;
      };
    }
  }
}

Not sure if there was some change in TypeScript that caused this or anything. If there are no reasons the docs shouldn't be changed to the above, I can help submit a PR.

πŸ–₯️ Reproduction in StackBlitz (if reporting incorrect content or code samples)

https://stackblitz.com/edit/stackblitz-webcontainer-api-starter-axxitg?file=src%2Fenv.d.ts

Cloudflare adapter and Esbuild fails despite using both the nodejs_compat and nodejs_compact flags

Astro Info

Astro                    v4.0.6
Node                     v18.16.0
System                   Linux (x64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             none

Describe the Bug

I have set up a project to deploy to Cloudflare when GitHub is updated, using this Cloudflare tutorial as my template. On commit to my repo, a build runs with esbuild and node-related failures, as shown below. I have added both the nodejs_compat and nodejs_compact flags in my cloudflare project settings.

7:22:34.835	23:22:34 [build] Rearranging server assets...
17:22:34.866	✘ [ERROR] Could not resolve "os"
17:22:34.867	
17:22:34.867	    node_modules/svgo/lib/svgo-node.js:3:19:
17:22:34.867	      3 β”‚ const os = require('os');
17:22:34.868	        β•΅                    ~~~~
17:22:34.868	
17:22:34.868	  The package "os" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
17:22:34.868	
17:22:34.868	✘ [ERROR] Could not resolve "fs"
17:22:34.868	
17:22:34.868	    node_modules/svgo/lib/svgo-node.js:4:19:
17:22:34.869	      4 β”‚ const fs = require('fs');
17:22:34.869	        β•΅                    ~~~~
17:22:34.869	
17:22:34.869	  The package "fs" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
17:22:34.869	
17:22:34.869	✘ [ERROR] Could not resolve "url"
17:22:34.871	
17:22:34.871	    node_modules/svgo/lib/svgo-node.js:5:34:
17:22:34.871	      5 β”‚ const { pathToFileURL } = require('url');
17:22:34.871	        β•΅                                   ~~~~~
17:22:34.871	
17:22:34.872	  The package "url" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
17:22:34.872	
17:22:34.872	✘ [ERROR] Could not resolve "path"
17:22:34.872	
17:22:34.872	    node_modules/svgo/lib/svgo-node.js:6:21:
17:22:34.872	      6 β”‚ const path = require('path');
17:22:34.872	        β”‚                      ~~~~~~
17:22:34.873	        β•΅                      "./path"
17:22:34.873	
17:22:34.873	  The package "path" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
17:22:34.873	
17:22:35.227	Could not resolve "os"
17:22:35.227	  Stack trace:
17:22:35.227	    at failureErrorWithLog (/opt/buildhome/repo/node_modules/esbuild/lib/main.js:1650:15)
17:22:35.228	    at /opt/buildhome/repo/node_modules/esbuild/lib/main.js:1003:52
17:22:35.228	    at /opt/buildhome/repo/node_modules/esbuild/lib/main.js:1085:16
17:22:35.228	    at handleIncomingPacket (/opt/buildhome/repo/node_modules/esbuild/lib/main.js:763:9)
17:22:35.228	    at Socket.emit (node:events:514:28)
17:22:35.258	Failed: Error while executing user command. Exited with error code: 1
17:22:35.268	Failed: build command exited with code: 1
17:22:36.277	Failed: error occurred while running build command

What's the expected result?

A successful build

Link to Minimal Reproducible Example

https://github.com/capndave/lilnonnas-astro

Participation

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

Allow Third-Party override of esbuild expose settings

Objective: We aim to enhance our adapter's flexibility and customization capabilities by exposing a subset of esbuild settings. This will enable third-party developers to override the default configurations set by our adapter with custom ones tailored to their specific needs. And to implement workarounds needed.

Background: Our current setup comes with a default configuration for esbuild that suits most use cases and follows the best-practices. However, we acknowledge the diversity of our user base and their unique requirements. By opening up the adapter for configuration overrides, we can accommodate a wider range of use-cases.

Scope of Work:

We think considering all esbuild settings should be the goal. The API could work similar to Astro's inline Vite config. Definitely we should support, external, plugins, platform, conditions

Overrides: It is important to note that, in this initial idea, we will not support merging custom configurations with the default settings. Users will need to specify their configurations fully, as these will entirely replace the defaults.

Considerations: Depending on the amount of work, we may want to opt for configuration merging. This would allow users to modify only parts of the configuration while keeping the rest as defaults.

Guidelines:

Docs: The implementation should be followed by clear documentation in the https://github.com/withastro/docs repository.

Tests: The implementation should also be provided with suitable tests (preferably using the node test runner #150)


Support: If you have any questions or need clarification on the task, please ask in the comments section of this issue early and often. Our team is here to help and provide guidance.

@astrojs/cloudflare - Robot.txt not valid

Astro Info

Astro                    v3.5.5
Node                     v20.9.0
System                   Windows (x64)
Package Manager          npm
Output                   hybrid
Adapter                  @astrojs/cloudflare
Integrations             @astrojs/tailwind
                         @astrojs/sitemap

Describe the Bug

PageSpeed said that Robot.txt is not valid

What's the expected result?

A valid Robot

Link to Minimal Reproducible Example

https://pagespeed.web.dev/analysis/https-rodrigotome-es/ee7rnvsq5l?form_factor=mobile

Participation

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

Trying to set `setBuildersTtl` for @astrojs/netlify resolve in error 500

What version of astro are you using?

2.8.3

Are you using an SSR adapter? If so, which one?

Netlify

What package manager are you using?

yarn

What operating system are you using?

Mac

What browser are you using?

Chrome

Describe the Bug

Follwing the documentation, it said that to edit the TTL of the on-demand builder function we need to add:

Astro.locals.runtime.setBuildersTtl(60);

However if we add this line to any of our pages we get a 500 error.

If we try to put it in the layout we get:

[TypeError](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) - Cannot read properties of undefined (reading 'setBuildersTtl')

--

How can we edit the TTL for the on-demand builder? Is it also possibile to set different TTL for different pages?

What's the expected result?

Not returning an error.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-dvd5l9?file=src%2Fpages%2Findex.astro

Participation

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

Netlify adapter, can't opt out image service

Astro Info

main

Describe the Bug

The new version of Netlify adapter doesn't allow to opt out of the image service used by Netlify.

What's the expected result?

Like the Vercel adapter, I would expect an option, because the Netlify image service doesn't support remote patterns out of the box.

Link to Minimal Reproducible Example

None

Participation

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

Error when trying to install @astrojs/[email protected] with [email protected]

Astro Info

Astro                    v4.0.3
Node                     v20.10.0
System                   macOS (arm64)
Package Manager          npm
Output                   hybrid
Adapter                  none
Integrations             @astrojs/tailwind

Describe the Bug

I couldn't install the latest Netlify adpater version (v3.1.0). I believe the problem comes from its package.json which reads:

  "peerDependencies": {
    "astro": "^3.0.0 | ^4.0.0"
  },

Cloudflare adapter uses two pipes for the same line: "astro": "^3.0.0 || ^4.0.0"

Here is the resulting error when running `npm install @astrojs/netlify@^3.1.0:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/astro
npm ERR!   astro@"^4.0.3" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer astro@"^3.0.0 | ^4.0.0" from @astrojs/[email protected]
npm ERR! node_modules/@astrojs/netlify
npm ERR!   @astrojs/netlify@"^3.1.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

What's the expected result?

We should be able to install the latest @astrojs/netlify via npm or @astrojs/upgrade

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-gbpw5b-mylecw?file=README.md

Participation

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

SSR Rendering Error with HTML Streaming leads to Timeout

Astro Info

not needed

Describe the Bug

When a page throws an exception, everything works fine in local dev, but in prod it leads to a function timeout.

---
throw new Error("I will blow up at runtime πŸ’₯");
---

This page should never be seen, because an error was thrown on render.

This also happens for netlify serve locally, so it seems to be something about the interplay of the adapter and netlify's code.

Discovered via Support case in Discord forums: https://discord.com/channels/830184174198718474/1187617912702373949/1187617912702373949

What's the expected result?

It should show an error page.

Link to Minimal Reproducible Example

see snippet above

Participation

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

CloudFlare adapter crashes when package.json is modified

Astro Info

Astro                    v4.1.3
Node                     v20.10.0
System                   macOS (arm64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             @astrojs/react

Describe the Bug

When running an Astro server with the CloudFlare adapter and local runtime enabled, e.g.:

export default defineConfig({
  output: "server",
  adapter: cloudflare({
    mode: "directory",
    runtime: {
      mode: "local",
    }
  )}
})

Changes to package.json cause the server to crash with this error:

20:14:51 Configuration file updated. Restarting...
20:14:51 [@astrojs/cloudflare] Cleaning up the local Cloudflare runtime.
20:14:51 [WARN] [@astrojs/cloudflare] The current configuration does not support image optimization. To allow your project to build with the original, unoptimized images, the image service has been automatically switched to the 'noop' option. See https://docs.astro.build/en/reference/configuration-reference/#imageservice
20:14:52 [ERROR] [UnhandledRejection] Astro detected an unhandled rejection. Here's the stack trace:
MiniflareCoreError [ERR_DISPOSED]: Cannot use disposed instance
    at #checkDisposed (/Users/alexturpin/src/bettertax/node_modules/miniflare/dist/src/index.js:8982:13)
    at #waitForReady (/Users/alexturpin/src/bettertax/node_modules/miniflare/dist/src/index.js:8943:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async LocalPagesRuntime.getBindings (file:///Users/alexturpin/src/bettertax/node_modules/@astrojs/cloudflare/dist/utils/local-runtime.js:69:9)
    at async middleware (file:///Users/alexturpin/src/bettertax/node_modules/@astrojs/cloudflare/dist/index.js:64:42)
  Hint:
    Make sure your promises all have an `await` or a `.catch()` handler.
  Error reference:
    https://docs.astro.build/en/reference/errors/unhandled-rejection/
  Stack trace:
    at /Users/alexturpin/src/bettertax/node_modules/miniflare/dist/src/index.js:8982:13
    [...] See full stack trace in the browser, or rerun with --verbose.
20:14:52 [ERROR] [UnhandledRejection] Astro detected an unhandled rejection. Here's the stack trace:
MiniflareCoreError [ERR_DISPOSED]: Cannot use disposed instance
    at #checkDisposed (/Users/alexturpin/src/bettertax/node_modules/miniflare/dist/src/index.js:8982:13)
    at #waitForReady (/Users/alexturpin/src/bettertax/node_modules/miniflare/dist/src/index.js:8943:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async LocalPagesRuntime.getBindings (file:///Users/alexturpin/src/bettertax/node_modules/@astrojs/cloudflare/dist/utils/local-runtime.js:69:9)
    at async middleware (file:///Users/alexturpin/src/bettertax/node_modules/@astrojs/cloudflare/dist/index.js:64:42)
  Hint:
    Make sure your promises all have an `await` or a `.catch()` handler.
  Error reference:
    https://docs.astro.build/en/reference/errors/unhandled-rejection/
  Stack trace:
    at #checkDisposed (/Users/alexturpin/src/bettertax/node_modules/miniflare/dist/src/index.js:8982:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    [...] See full stack trace in the browser, or rerun with --verbose.

At first I thought this was happening randomly, but once I realized it was package.json I can just insert empty new lines in it and it crashes the server every time.

What's the expected result?

Changing package.json should not crash the server.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-6dftoj?file=package.json

Participation

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

A different D1 database is created when there is already a migrated D1 database

Astro Info

Astro                    v3.5.4
Node                     v18.16.1
System                   macOS (arm64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             none

Describe the Bug

please run local migrate -> dev -> press add user button

What's the expected result?

D1_ERROR: no such table: user does not occer

Link to Minimal Reproducible Example

https://github.com/sor4chi/repro-astro-cloudflare-d1

Participation

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

Unable to route to API using Netlify adapter

Astro Info

Astro                    v4.1.0
Node                     v20.10.0
System                   Windows (x64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/netlify
Integrations             none

Describe the Bug

I am having an issue with the Netlify adapter.

I am deploying my Astro front end with SSR enabled using continual deployment from my Github repository. For the back-end I have an API created in Strapi I am hosting on Digital Ocean.

I created an [id].astro page in the pages directory and a fetch API on the same page which allows me to look up an object in my array by ID and dynamically put the ID in the link. So far it is working fine on localhost, but does not work when I deploy the site to Netlify. Here is what my Astro.config.mjs looks like

What's the expected result?

On localhost when I call the API, it gives me an ID, then routes the page to that ID (in my case, the path should be going to /sheets/[id]. When deployed on Netlify however, it throws me a 404 page.

I was also following the steps of this article, but it seems the information is out of date since Astro throws an error when you attempt to include import netlify from "@astrojs/netlify/edge-functions". For now I have left that line as import netlify from '@astrojs/netlify';.

Link to Minimal Reproducible Example

https://sgxp.me/sprites

Participation

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

Server-rendered 404 pages no longer work on Cloudflare

What version of astro are you using?

2.9.7 to 3.3.2

Are you using an SSR adapter? If so, which one?

Cloudflare

What package manager are you using?

npm

What operating system are you using?

Linux & Deployment

What browser are you using?

Chrome

Describe the Bug

Issue: Changes to 404 handling have resulted in server-rendered 404 pages no longer working on Cloudflare.

Behaviors in different versions

Expected behavior:

  1. The 404 page loads when going to a non-existent route
  2. The 404 page can perform redirects to case-corrected versions of pages or aliases will redirect to correct page
    • Examples:
      • /eXaMPLe can be redirected to /example
      • /index can be redirected to /
  • These behaviours are tested to work in Astro v2.9.6 with Cloudflare adapter v6.6.2

Updated behavior with Astro v2.9.7 and higher

  1. Cloudflare sends a default 404 error with no page when accessing a non-existent route
  2. The 404 page still can be accessed from /404
  3. Case-corrections and aliases will not be redirected
  • These behaviours are tested to work in Astro v2.9.7 and higher with Cloudflare adapter v6.6.2

Updated behavior with Cloudflare adapter v6.7.0 and higher

  1. Cloudflare returns with the contents of the index route without redirecting or updating the url when accessing a non-existent route
  2. The 404 page still can be accessed from /404
  3. Case-corrections and aliases still will not be redirected
  • These behaviours are tested to work in Astro v2.10.5 and higher with Cloudflare adapter v6.7.0 and higher and is the current behavior on latest versions of both.

This issue does not happen on latest when prerendering the 404 page

However, this doesn't allow you to use the 404 page to do case-corrections and handle aliases

  • The latest-prerendered deployment in my provided example dedicated to this behavior

Deployments and their issues

Deployment Bad Routes Aliases Case-correction
[email protected] Returns 404.astro Working Working
[email protected] Returns nothing Configured redirects only Not working
[email protected]@6.6.2 Returns nothing Configured redirects only Not working
[email protected]@6.7.0 Returns index.astro Configured redirects only Not working
latest Returns index.astro Configured redirects only Not working
latest-prerendered Renders 404.astro Configured redirects only Not working

What's the expected result?

  1. The 404 page loads when going to a non-existent route
  2. The 404 page can perform redirects to case-corrected versions of pages or aliases will redirect to correct page
    • Examples:
      • /eXaMPLe can be redirected to /example
      • /index can be redirected to /
  • These behaviours are tested to work in Astro v2.9.6 with Cloudflare adapter v6.6.2

Link to Minimal Reproducible Example

https://github.com/ToxiWoxi/astro-404-issue

Participation

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

deduplication does not work

Describe the Bug

The deduplicatePatterns of _routes.json still doesn't work

What's the expected result?

Correct deduplication of:

{
  "version": 1,
  "include": [
    "/",
    "/u/*",
    "/login",
    "/_image",
    "/sign-up",
    "/discover/*",
    "/freelancer",
    "/login/utils",
    "/api/auth/login",
    "/login/services",
    "/api/auth/logout",
    "/discover/*/utils"
  ],
  "exclude": []
}

Participation

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

Erron when hosting in Cloudflare with Server Side Rendering enabled

What version of astro are you using?

2.7.4

Are you using an SSR adapter? If so, which one?

Cloudflare

What package manager are you using?

npm

What operating system are you using?

Mac

What browser are you using?

Chrome, Firefox

Describe the Bug

We are using the Server Side Rendering mode with Cloudflare adapter to host our Astro project. We need the SSR mode as we pull the content from the CMS (Storyblok) and to have the live preview it requires Server Side Render pages instead of static generated pages which we are using in production.

While this works fine we have noticed many random errors if we request a page two many times by pressing F5 constantly. When looking into the logs of the cloudflare projects we see the following error

{
  "outcome": "exception",
  "scriptName": "pages-worker--1209979-production",
  "exceptions": [
    {
      "name": "Error",
      "message": "The script will never generate a response.",
      "timestamp": 1688555913177
    }
  ],
}

which is also described in more details here. Initially we thought that this happens because we fetch data during SSR from an API and something goes wrong there.

When we created a really simple page in Astro that doesn't fetch any content from the CMS and deployed it again we had the same behavior.

We tried both advanced and directory mode.

What's the expected result?

Pages should render properly regardless how many times we request them.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-tkyzda-4d7fjz?file=astro.config.mjs

Participation

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

Cloudflare adapter build fail when using pg lib

Astro Info

Astro                    v3.2.3
Node                     v18.17.1
System                   Linux (x64)
Package Manager          bun
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             @astrojs/tailwind

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

linux

Describe the Bug

Trying to run astro build on a Cloudflare project using the lib pg. PG is supported by cloudflare workers.

✘ [ERROR] Could not resolve "events"

    node_modules/pg/lib/native/client.js:12:27:
      12 β”‚ var EventEmitter = require('events').EventEmitter
         β•΅                            ~~~~~~~~

  The package "events" wasn't found on the file system but is built into node. Are you trying to
  bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "util"

    node_modules/pg/lib/native/client.js:13:19:
      13 β”‚ var util = require('util')
         β•΅                    ~~~~~~

  The package "util" wasn't found on the file system but is built into node. Are you trying to
  bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "net"

    node_modules/pg/lib/connection.js:3:18:
      3 β”‚ var net = require('net')
        β•΅                   ~~~~~

  The package "net" wasn't found on the file system but is built into node. Are you trying to bundle
  for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "assert"

    node_modules/pg-protocol/dist/parser.js:9:41:
      9 β”‚ const assert_1 = __importDefault(require("assert"));
        β•΅                                          ~~~~~~~~

  The package "assert" wasn't found on the file system but is built into node. Are you trying to
  bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "net"

    node_modules/pg/lib/stream.js:6:22:
      6 β”‚   const net = require('net')
        β•΅                       ~~~~~

  The package "net" wasn't found on the file system but is built into node. Are you trying to bundle
  for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "tls"

    node_modules/pg/lib/stream.js:21:20:
      21 β”‚   var tls = require('tls')
         β•΅                     ~~~~~

What's the expected result?

I'm not sure, but PG lib is supported by cloudflare. https://developers.cloudflare.com/workers/tutorials/postgres/#4-connect-to-the-postgresql-database-in-the-worker

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-ig3cma?file=astro.config.mjs

Participation

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

EDIT by @alexanderniebuhr: more context at https://discord.com/channels/830184174198718474/1159635481902972928

Server API fails to import a node package that works on Cloudflare Workers using `node_compat`

Astro Info

Astro                    v3.3.2
Node                     v18.18.0
System                   Linux (x64)
Package Manager          unknown
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             none

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

No response

Describe the Bug

I have a running cloudflare worker that is based on this tutorial. It uses the qr-image npm package that works as expected with their node_compat flag.

I'm trying to port it as an Astro server API. But astro build fails during Rearranging server assets... with ERROR: Could not resolve "stream" & "zlib".

What's the expected result?

A working build.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/node-akfuos?file=src%2Fpages%2Fapi.ts,package.json

Participation

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

Netlify request vs run time

Astro Info

Astro                    v4.2.7
Node                     v18.18.2
System                   Linux (x64)
Package Manager          npm
Output                   hybrid
Adapter                  @astrojs/netlify
Integrations             @astrojs/starlight
                         @astrojs/tailwind
                         @astrojs/react

Describe the Bug

I have deployed an hybrid app yesterday and I have reached the max number of requests per function in netlify with zero runtime seconds, how is this even possible?

Other considerations:
my use base is around 100 users per day, we can discard the possibility of that many number of users;
the requests numbers jump around 20.000 each time. My app has approximately that number of files, which are consumed by the only function I have. Can that be the problem?

image

What's the expected result?

I would expect to have a 1000 max requests per day.

Link to Minimal Reproducible Example

https://github.com/tesourofieis/tesourofieis

Participation

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

Netlify adapter throws error with output: "server"

Astro Info

Astro                    v3.5.2
Node                     v20.9.0
System                   Windows (x64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/netlify
Integrations             @astrojs/tailwind

Describe the Bug

It throws an error if the output: "server" set in the astro.config.
"static" and "hybrid" mode works well.

Nov 10, 11:54:05 PM: 2023-11-10T22:54:05.604Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Error","errorMessage":"Cannot find package '@astrojs/netlify' imported from /var/task/.netlify/functions-internal/entry.mjs","code":"ERR_MODULE_NOT_FOUND","stack":["Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@astrojs/netlify' imported from /var/task/.netlify/functions-internal/entry.mjs","    at new NodeError (node:internal/errors:405:5)","    at packageResolve (node:internal/modules/esm/resolve:895:9)","    at moduleResolve (node:internal/modules/esm/resolve:988:20)","    at moduleResolveWithNodePath (node:internal/modules/esm/resolve:939:12)","    at defaultResolve (node:internal/modules/esm/resolve:1181:79)","    at nextResolve (node:internal/modules/esm/loader:163:28)","    at ESMLoader.resolve (node:internal/modules/esm/loader:835:30)","    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)","    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)","    at link (node:internal/modules/esm/module_job:76:36)"]}Nov 10, 11:54:05 PM: INIT_REPORT Init Duration: 212.75 ms	Phase: invoke	Status: error	Error Type: Runtime.ExitError

What's the expected result?

Start working on netlify.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-o3ve7p?file=astro.config.mjs

Participation

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

β˜‚οΈ Move Adapters tests to `node:test`

Description

Internally, the team decided to move our testing infrastructure to use node:test instead of Mocha.

While Mocha is good, it has its own quirks. Also, we believe that the Node.js test runner will improve with time.

This is an excellent opportunity to contribute to Astro and help us with the migration because you don't need to understand Astro logic. So if you have been looking for an opportunity to contribute to Astro, this is the perfect chance for you!

Plan

Comment here which integration/adapter you want to migrate first. Failing to comment might nullify your contribution if someone else did the work and commented on the issue. This will help us to avoid having multiple people working on the same thing.

The plan should be as follows:

  1. Migrate tests of our @astrojs/* packages. You can use this PR as a blueprint of what we're looking for, however this repository might be a little different, so this can only be used as a reference: withastro/astro#9758

Integrations/adapters

List of the integrations/adapters

Cloudflare Image Resizing SSG

  • have a Cloudflare SSG adpater
  • have the image service in a separate package
  • configured as part of the adapter, you'd still need a static adapter
  • could export a function that does the config for you, much like we have in astro/config

Routing issues with tsx components

Astro Info

Astro                    v3.4.4
Node                     v18.18.0
System                   Windows (x64)
Package Manager          pnpm
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             @astrojs/tailwind
                         @astrojs/react
                         @astrojs/mdx

Describe the Bug

A continuation of a Discord discussion, hard to parse as half is in a thread while some isn't , but the convo starts here (for easy tracking)

When using Cloudflare, we're hitting an issue with the routes file being over 100 lines long. Investigating, a lot are tsx components, and fonts. using strategy: "include" in a public repo didn't help (output is in the README), and in a private repo I can't share the code for only generated

So something is causing tsx & fonts to be added to the routes. Speaking with Alex in Discord, we decided to move forward to an issue to help work on this πŸ’ͺ

What's the expected result?

Hopefully a correctly generated routes.json that'll stop problems with the 100 limit, but work as expected . A workaround right now is a manually created file, which isn't going to be best in the long run we imagine and want to help get this feature up and running correctly as we imagine it'll be vital to us in the future.

I don't have a minimal reproducible, only a public repo currently. I'll try add one tomorrow (it's getting late and I got work)

Link to Minimal Reproducible Example

https://github.com/doras-to/doras/tree/route-checking

Participation

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

Astro Cloudflare - Error: Failed to publish your Function. Got error: Error 8000057: Rules in `_routes.json` are over the 100 rule limit.

Astro Info

Astro                    v4.3.0
Node                     v20.6.1
System                   macOS (arm64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             @astrojs/solid-js
                         @astrojs/tailwind

Describe the Bug

Hey, I'm building an Astro site with server side rendering using Cloudflare Pages with server side rendering with the following dynamic paths:
/car/[colorId].astro
/[users]/index.astro

and when I submit to workers I get this error and a failed deployment.

#135 (comment)

08:49:49.373 | Found _worker.js in output directory. Uploading.
-- | --
08:49:50.846 | ✨ Compiled Worker successfully
08:49:50.895 | Found _routes.json in output directory. Uploading.
08:49:50.910 | Validating asset output directory
08:49:51.627 | Deploying your site to Cloudflare's global network...
08:49:56.287 | Uploading... (353/422)
08:49:57.090 | Uploading... (376/422)
08:49:57.218 | Uploading... (399/422)
08:49:57.550 | Uploading... (422/422)
08:49:57.550 | ✨ Success! Uploaded 69 files (353 already uploaded) (1.72 sec)
08:49:57.550 | Β 
08:49:58.142 | ✨ Upload complete!
08:50:01.603 | Success: Assets published!
08:50:09.419 | Error: Failed to publish your Function. Got error: Error 8000057: Rules in `_routes.json` are over the 100 rule limit. Refer to https://cfl.re/3FsE4aF.

What's the expected result?

A successful deployment with a working site.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-7e2amg?file=src%2Fpages%2Findex.astro

Participation

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

netlify adapter doesn't work with base

Astro Info

Astro                    v3.4.0
Node                     v18.14.1
System                   Windows (x64)
Package Manager          pnpm
Output                   server
Adapter                  @astrojs/netlify
Integrations             @astrojs/mdx
                         @astrojs/sitemap

Describe the Bug

When setting a base, deployment actually serves files from the root. I don't know if that's caused by setting output to server.

For example, site is available at https://astro-netlify-base-test.netlify.app/ but should only be at https://astro-netlify-base-test.netlify.app/test, which thows a 404

What's the expected result?

Base should be taken into account

Link to Minimal Reproducible Example

https://github.com/florian-lefebvre/astro-netlify-base-test

Participation

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

Issues with Script Contents and Durable Objects in Miniflare Local Development

Astro Info

Astro                    v4.0.3
Node                     v18.16.0
System                   macOS (arm64)
Package Manager          bun
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             @astrojs/tailwind
                         @astrojs/react
                         @astrojs/partytown
                         astro-robots-txt

Describe the Bug

Relevant Opened Issue
Relevant Opened Issue 2

Issue Summary:
I am experiencing two primary issues when using the Astro Cloudflare adapter with Miniflare for local development, specifically when working with script contents necessary for Durable Objects.

Issue 1: Script Contents Required for Durable Objects
In a Cloudflare Workers environment, scripts are essential for the functionality of Durable Objects. However, when attempting to replicate this setup in Miniflare, the script contents do not seem to be recognized or executed as expected. This has become a blocker for local development and testing of Durable Objects.

Issue 2: Errors with Fetch Method in Durable Objects
When interacting with Durable Objects through the fetch method, I encounter the following errors:

Error: "Failed to parse URL from [object Request]"

This error occurs when using stub.fetch(ctx.request). It appears that the fetch method is not able to process the Request object as it would in a typical Cloudflare Workers environment.
Error: "The middleware returned something that is not a Response object."

Altering the code to stub.fetch(ctx.request.url) resolves the first error but introduces this new error. The middleware returned something that is not a 'Response' object. Despite the Durable Object's fetch method returning a valid Response object, Astro seems to misinterpret the returned value.

Environment:
Framework/Library: Astro Cloudflare adapter
Local Development Tool: Miniflare

Actual Behavior:
Script contents for Durable Objects are not functioning as expected in the Miniflare environment.
Fetch method calls result in errors, hindering the development and testing of Durable Objects locally.

What's the expected result?

Expected Behavior:
The script contents necessary for Durable Objects should be recognized and executed similarly to how they work in the Cloudflare Workers environment.
The fetch method on a Durable Object stub should accept a Request object and return a Response object without errors, mirroring the behavior in Cloudflare Workers.

Link to Minimal Reproducible Example

TBF

Participation

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.