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

Astro DB on Cloudflare: Build fails with "Cannot create a remote client: missing app token" error. #10872

Open
1 task
pMay2021 opened this issue Apr 24, 2024 · 5 comments
Labels
needs response Issue needs response from OP

Comments

@pMay2021
Copy link

pMay2021 commented Apr 24, 2024

Astro Info

Astro                    v4.6.4
Node                     v21.7.3
System                   macOS (arm64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             @astrojs/tailwind
                         @astrojs/mdx
                         astro:db
                         @astrojs/db/file-url

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

No response

Describe the Bug

My Cloudflare account deploys automatically on GitHub checkin.

Astro DB works fine local and with --remote (though I've been seeing some ENETUNREACH today but let's park that).

Deployment on Cloudflare fails with the following error:

Success: Assets published!
15:21:40.397	Error: Failed to publish your Function. Got error: Uncaught Error: Cannot create a remote client: missing app token.
  at chunks/pages/404_MemiTqFJ.mjs:18015:11 in createRemoteDatabaseClient
  at chunks/pages/404_MemiTqFJ.mjs:18234:18

ASTRO_STUDIO_APP_TOKEN = value, is set on Cloudflare settings.

My configuration is this:

export default defineConfig({
  integrations: [tailwind(), mdx(), db()],
  output: "server",
  adapter: cloudflare()
});

Not sure what else to do.

What's the expected result?

Build to complete and deploy.

Link to Minimal Reproducible Example

It's on my CF deployment.

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Apr 24, 2024
@matthewp
Copy link
Contributor

We had some downtime earlier today. Can you confirm that you're still experiencing this?

@pMay2021
Copy link
Author

@matthewp still seeing both the errors.

  1. On my local dev machine, I keep facing the following intermittently:
18:17:01 [ERROR] [Astro DB Error] request to https://gbaimk52fwt9fulhykeljirqxnif-astro.turso.io/v2/pipeline failed, reason: connect ENETUNREACH 2a09:8280:1::6:d39d:443

  1. And when I check in code, the same app token error appears again.

18:19:35.576	Success: Assets published!
18:19:37.675	Error: Failed to publish your Function. Got error: Uncaught Error: Cannot create a remote client: missing app token.
  at chunks/pages/404_MemiTqFJ.mjs:18015:11 in createRemoteDatabaseClient
  at chunks/pages/404_MemiTqFJ.mjs:18234:18

  1. npm run build does not throw any error for me.

@ematipico
Copy link
Member

@pMay2021 are you providing the environment variable ASTRO_STUDIO_APP_TOKEN? You should provide either via CI or via CLI

@ematipico ematipico added needs response Issue needs response from OP and removed needs triage Issue needs to be triaged labels Apr 25, 2024
@matthewp
Copy link
Contributor

Locally they would not need the token, it gets retrieved as long as they are logged in. @pMay2021 Can you try logging in again locally? I doubt that's the problem but would help to isolate.

@pMay2021
Copy link
Author

pMay2021 commented Apr 25, 2024

Hi @matthewp what do you mean "login locally"? There's no issue on my local machine. But unfortunately this morning I'm hitting the request to https://gbaimk52fwt9fulhykeljirqxnif-astro.turso.io/v2/pipeline failed, reason: connect ENETUNREACH 2a09:8280:1::6:d39d:443 repeatedly on --remote. I think all three issues are linked to the DB implementation

  1. The ENETUNREACH that occurs frequently (not always; because when I refresh my pages it goes through sometimes and sometimes not)
  2. The failure to do a --force-reset
  3. The failure on Cloudflare build

Stackblitz reproduction

I'm unable to reproduce on Stackblitz. Astro DB doesn't install. I get an error saying

Command failed with exit code 1: npm install @astrojs/db@^0.10.6
npm ERR! code ERR_INVALID_PROTOCOL
npm ERR! Protocol "https:" not supported. Expected "http:"

and when I tried to install manually, I get:

vite] Error when evaluating SSR module /home/projects/github-wdwm38/astro.config.mjs: failed to import "@astrojs/db"
|- Error: Cannot find module '@astrojs/db' imported from '/home/projects/github-wdwm38/astro.config.mjs'

here's the link to a very basic project:

https://stackblitz.com/edit/github-wdwm38?file=astro.config.mjs (it won't built and fails with an error)

I have a question - how do I make the remote database connection work from Stackblitz? I've created a temp token on Studio, do I give it to you to paste it in a .env?

(PS - I apologize if I'm missing something basic. I'm new to a lot of this--but I love Astro though!).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs response Issue needs response from OP
Projects
None yet
Development

No branches or pull requests

3 participants