Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

add option to disable async local storage in astro #265

Open
4 tasks
samuelstroschein opened this issue Dec 1, 2024 — with Linear · 0 comments
Open
4 tasks

add option to disable async local storage in astro #265

samuelstroschein opened this issue Dec 1, 2024 — with Linear · 0 comments

Comments

Copy link
Member

samuelstroschein commented Dec 1, 2024

Context

The Astro adapter doesn't work when deploying to cloudflare workers.

Serverless environments like Cloudflare workers have no risk of cross request problems. Async Local Storage, which is used to avoid cross request bugs in the Astro adapter, is not needed in those environments and also not available.

Proposal

Add an option to disable AsyncLocalStorage similar to the SvelteKit adapter #163 (comment).

Tasks

  • add option in the paraglide astro integration disableAsyncLocalStorage
integrations: [
	paraglide({
		// recommended settings
		project: "./project.inlang",
		outdir: "./src/paraglide",
+       disableAsyncLocalStorage: true
	}),
],
export function integration(integrationConfig: {
	project: string
	outdir: string
+   disableAsyncLocalStorage: boolean
}): AstroIntegration {
	return {
		name: "paraglide",
		hooks: {
			"astro:config:setup": async ({ addMiddleware, updateConfig, injectScript }) => {
				//Register the middleware
				addMiddleware({
					order: "pre", //Run before user-defined middleware (why not?)
-					entrypoint: middlewarePath,
+                   entrypoint: disableAsyncLocalStorage ? middlewarePathNoAsyncLocalStorage : middlewarePath
				})
  • update documentation to explain that async local storage can be disabled for cloudflare workers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant