withastro / adapters Goto Github PK
View Code? Open in Web Editor NEWHome for Astro's core maintained adapters
Home for Astro's core maintained adapters
We need a custom endpoint
, due to Buffer.from
which is not support on Cloudflare Runtime. We will use the generic
endpoint from core, without Node Buffer
https://canary.discord.com/channels/830184174198718474/845430950191038464/1171883769410621522
https://canary.discord.com/channels/830184174198718474/1171625875901534258
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
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: }
I should be able to get the user's IP
Here you can see what I tried EddyVinck/astro-engineering-blog@5827c40
Astro v4.2.6
Node v18.17.0
System macOS (arm64)
Package Manager unknown
Output server
Adapter @astrojs/cloudflare
Integrations @astrojs/tailwind
@astrojs/react
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?
Works just like Cloudflare (as the declarations are available via:
/// <reference types="@cloudflare/workers-types" />
https://stackblitz.com/edit/github-8ghpcm?file=src%2Fpages%2Findex.ts
Astro v4.0.6
Node v20.9.0
System macOS (x64)
Package Manager npm
Output server
Adapter @astrojs/cloudflare
Integrations @sanity/astro
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:
<Code>
is usednode
adapter even with <Code>
Thanks
The build should succeed.
https://codesandbox.io/p/devbox/suspicious-wozniak-82gcxq
Astro v4.0.7
Node v18.15.0
System macOS (arm64)
Package Manager pnpm
Output static
Adapter @astrojs/netlify
Integrations @astrojs/react
@astrojs/starlight
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
It should point to https://github.com/withastro/adapters/tree/main/packages/netlify#netlify-image-cdn-support
none
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
No response
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/*",
// ...
]
}
{
"version": 1,
"include": [
"/*"
],
"exclude": [
"/companies/*",
"/blog/*",
// ...
]
}
https://stackblitz.com/edit/withastro-astro-cykvsk?file=dist%2F_routes.json
We want to refactor runtime support using getBindingsProxy
, if we can't get workerd
runtime.
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
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
The Netlify README contains a reference to @astrojs/netlify/functions
, but the import is deprecated. Docs fixed in withastro/docs#5977, but the README still needs an update.
Astro v4.1.3
Node v19.9.0
System macOS (x64)
Package Manager npm
Output server
Adapter @astrojs/cloudflare
Integrations @astrojs/lit
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
I expected the Function to be able to be published after being built successfully. Everything local is working fine.
https://github.com/dengel29/dngl
We need to also make sure do check this repo for: withastro/astro#9168
astro
are you using?2.8.3
Netlify
yarn
Linux
Chromium
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?
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.
https://stackblitz.com/edit/github-zfmbew?file=astro.config.mjs
Astro v4.2.4
Node v18.19.0
System Windows (x64)
Package Manager yarn
Output hybrid
Adapter @astrojs/netlify
Integrations @astrojs/mdx
@astrojs/sitemap
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
The rewrite should work, not return a 404.
https://github.com/florian-lefebvre/astro-netlify-redirects-repro
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
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.
pnpm dev
works
Removing the directory fixes the problem permanently: rm -r node_modules/.astro/
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
astro
are you using?2.7.2
Netlify 2.3.0
npm
Mac
Chrome
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.
SSR routes should work on Netlify regardless of rest parameter dynamic static route at the root.
https://github.com/regisphilibert/astro-issue-repro-netlify-ssr
Astro v4.3.0
Node v20.10.0
System macOS (arm64)
Package Manager npm
Output server
Adapter @astrojs/cloudflare
Integrations @astrojs/react
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.
A project not using i18nDomains
should still work on the Cloudflare adapter
https://stackblitz.com/edit/github-k3ev6s?file=astro.config.mjs
astro
are you using?2.3.0
Cloudflare
yarn
Mac
Brave
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!
https://github.com/chaffinated/astro-lit-cloudflare-repro
We do have a memory leak, because we do start a new instance of miniflare for each request. Will have to rewrite that logic to be more robust using a factory class maybe
Astro v4.2.1
Node v21.1.0
System macOS (arm64)
Package Manager npm
Output hybrid
Adapter @astrojs/netlify
Integrations none
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.
When route is not found Netlify should serve its own 404 page or the project's own 404.html
https://github.com/regisphilibert/astro-netlify-404-repro
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
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
Build should not failed.
ca
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
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 {
...
}
}
It should work, at least when deployed.
N/A
Cloudflare adapter
https://docs.astro.build/en/guides/integrations-guide/cloudflare/#access-to-the-cloudflare-runtime
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.
https://stackblitz.com/edit/stackblitz-webcontainer-api-starter-axxitg?file=src%2Fenv.d.ts
Astro v4.0.6
Node v18.16.0
System Linux (x64)
Package Manager npm
Output server
Adapter @astrojs/cloudflare
Integrations none
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
A successful build
https://github.com/capndave/lilnonnas-astro
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.
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.
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.
Astro v3.5.5
Node v20.9.0
System Windows (x64)
Package Manager npm
Output hybrid
Adapter @astrojs/cloudflare
Integrations @astrojs/tailwind
@astrojs/sitemap
PageSpeed said that Robot.txt is not valid
A valid Robot
https://pagespeed.web.dev/analysis/https-rodrigotome-es/ee7rnvsq5l?form_factor=mobile
astro
are you using?2.8.3
Netlify
yarn
Mac
Chrome
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?
Not returning an error.
https://stackblitz.com/edit/github-dvd5l9?file=src%2Fpages%2Findex.astro
main
The new version of Netlify adapter doesn't allow to opt out of the image service used by Netlify.
Like the Vercel adapter, I would expect an option, because the Netlify image service doesn't support remote patterns out of the box.
None
I was following this recipe when using the Netlify Adapter.
When using the Netlify CLI and deploying to Netlify, the API route is not recognised.
A little bit of debugging by @estephinson suggests that the API route is treated as an asset.
Astro v4.0.3
Node v20.10.0
System macOS (arm64)
Package Manager npm
Output hybrid
Adapter none
Integrations @astrojs/tailwind
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.
We should be able to install the latest @astrojs/netlify via npm or @astrojs/upgrade
https://stackblitz.com/edit/github-gbpw5b-mylecw?file=README.md
not needed
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
It should show an error page.
see snippet above
Astro v4.1.3
Node v20.10.0
System macOS (arm64)
Package Manager npm
Output server
Adapter @astrojs/cloudflare
Integrations @astrojs/react
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.
Changing package.json should not crash the server.
https://stackblitz.com/edit/github-6dftoj?file=package.json
Astro v3.5.4
Node v18.16.1
System macOS (arm64)
Package Manager npm
Output server
Adapter @astrojs/cloudflare
Integrations none
please run local migrate -> dev -> press add user button
D1_ERROR: no such table: user
does not occer
https://github.com/sor4chi/repro-astro-cloudflare-d1
Astro v4.1.0
Node v20.10.0
System Windows (x64)
Package Manager npm
Output server
Adapter @astrojs/netlify
Integrations none
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
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';
.
astro
are you using?2.9.7 to 3.3.2
Cloudflare
npm
Linux & Deployment
Chrome
/eXaMPLe
can be redirected to /example
/index
can be redirected to /
However, this doesn't allow you to use the 404 page to do case-corrections and handle aliases
latest-prerendered
deployment in my provided example dedicated to this behaviorDeployment | 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 |
/eXaMPLe
can be redirected to /example
/index
can be redirected to /
https://github.com/ToxiWoxi/astro-404-issue
The deduplicatePatterns of _routes.json
still doesn't work
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": []
}
astro
are you using?2.7.4
Cloudflare
npm
Mac
Chrome, Firefox
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.
Pages should render properly regardless how many times we request them.
https://stackblitz.com/edit/github-tkyzda-4d7fjz?file=astro.config.mjs
Astro v3.2.3
Node v18.17.1
System Linux (x64)
Package Manager bun
Output server
Adapter @astrojs/cloudflare
Integrations @astrojs/tailwind
linux
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')
β΅ ~~~~~
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
https://stackblitz.com/edit/github-ig3cma?file=astro.config.mjs
EDIT by @alexanderniebuhr: more context at https://discord.com/channels/830184174198718474/1159635481902972928
Astro v3.3.2
Node v18.18.0
System Linux (x64)
Package Manager unknown
Output server
Adapter @astrojs/cloudflare
Integrations none
No response
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"
.
A working build.
https://stackblitz.com/edit/node-akfuos?file=src%2Fpages%2Fapi.ts,package.json
not needed
See #3 (comment)
We're importing a JSON file without a type assertion. Some versions of Node.js don't like that.
Importing the adapter should be fine.
not needed
Currently we unnecessarily block image optimization even if it could be used just fine on static pages (pre rendered pages). Using this mode, means no parallel SSR usage possible
Discussion took place at Discord: https://discord.com/channels/830184174198718474/830184175176122389/1170827297452998738
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
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?
I would expect to have a 1000 max requests per day.
https://github.com/tesourofieis/tesourofieis
Astro v3.5.2
Node v20.9.0
System Windows (x64)
Package Manager npm
Output server
Adapter @astrojs/netlify
Integrations @astrojs/tailwind
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
Start working on netlify.
https://stackblitz.com/edit/github-o3ve7p?file=astro.config.mjs
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!
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:
@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#9758List of the integrations/adapters
@astrojs/cloudflare
@astrojs/netlify
astro/config
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
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 πͺ
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)
https://github.com/doras-to/doras/tree/route-checking
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
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.
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.
A successful deployment with a working site.
https://stackblitz.com/edit/github-7e2amg?file=src%2Fpages%2Findex.astro
Astro v3.4.0
Node v18.14.1
System Windows (x64)
Package Manager pnpm
Output server
Adapter @astrojs/netlify
Integrations @astrojs/mdx
@astrojs/sitemap
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
Base should be taken into account
https://github.com/florian-lefebvre/astro-netlify-base-test
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
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.
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.
TBF
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.