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

Inspect why Sentry plugin breaks builds on CloudFlare Pages #6518

Closed
yangwao opened this issue Aug 2, 2023 · 20 comments · Fixed by #6523 or #6707
Closed

Inspect why Sentry plugin breaks builds on CloudFlare Pages #6518

yangwao opened this issue Aug 2, 2023 · 20 comments · Fixed by #6523 or #6707
Assignees
Labels
$$ ~51-150usd 🧙‍♀️ - bug-hunt A-maintenance A-vite p2 core functionality, or is affecting 60% of app

Comments

@yangwao
Copy link
Member

yangwao commented Aug 2, 2023

@preschian Okay, it's a sentry plugin. Seems builds.

Originally posted by @yangwao in #6470 (comment)

@yangwao yangwao added $$ ~51-150usd p2 core functionality, or is affecting 60% of app 🧙‍♀️ - bug-hunt labels Aug 2, 2023
@preschian
Copy link
Member

preschian commented Aug 3, 2023

after some further testing: preschian#67

  • netlify: ok
  • vercel: ok
  • cf-pages: error

It seems like a compatibility issue with the current nitro version on cf-pages
or
there is something wrong on cf-pages

@yangwao
Copy link
Member Author

yangwao commented Aug 5, 2023

We are so back when I've added Sentry AUTH token

18:51:49.040 | ^
-- | --
18:51:49.057 | 34099:       "img/logo-talisman.4e0808a.svg",
18:51:49.057 | 34100:       "img/logo-enkrypt.8a571eb.png",
18:51:49.058 | [fatal] Unexpected token (Note that you need plugins to import files that are not JavaScript)
18:51:49.058 | at error (node_modules/.pnpm/rollup@2.79.1/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
18:51:49.058 | at Module.error (node_modules/.pnpm/rollup@2.79.1/node_modules/rollup/dist/es/shared/rollup.js:12429:16)
18:51:49.058 | at Module.tryParse (node_modules/.pnpm/rollup@2.79.1/node_modules/rollup/dist/es/shared/rollup.js:12806:25)
18:51:49.058 | at Module.setSource (node_modules/.pnpm/rollup@2.79.1/node_modules/rollup/dist/es/shared/rollup.js:12711:24)
18:51:49.059 | at ModuleLoader.addModuleSource (node_modules/.pnpm/rollup@2.79.1/node_modules/rollup/dist/es/shared/rollup.js:21959:20)
18:51:49.158 | Finished
18:51:49.158 | Note: No functions dir at /functions found. Skipping.
18:51:49.159 | Validating asset output directory
18:51:52.017 | Deploying your site to Cloudflare's global network...
18:51:53.228 | Parsed 1 valid header rule.
18:51:55.620 | Uploading... (361/368)
18:51:56.220 | Uploading... (363/368)
18:51:57.518 | Uploading... (365/368)
18:51:58.623 | Uploading... (368/368)
18:51:58.624 | ✨ Success! Uploaded 7 files (361 already uploaded) (4.11 sec)
18:51:58.624 |  
18:51:59.319 | ✨ Upload complete!
18:52:07.529 | Success: Assets published!
18:52:08.578 | Success: Your site was deployed!

SENTRY_AUTH_TOKEN - 173e9a5537c643bd999c1f1f4b27a8a9467a51b5363b4b32b3134fe63b4eb664

@preschian
Copy link
Member

preschian commented Aug 7, 2023

We are so back when I've added Sentry AUTH token

hhmm, interesting 🤔

I added SENTRY_AUTH_TOKEN in preview branch (test-cf-preview), seems fine

Details

image

Uploading... (368/368)

maybe that is still deploying old commits? Because right now, our files are Uploading... (414/414)

@preschian
Copy link
Member

maybe @prury want to test also?

how to test:

  1. fork nft-gallery
  2. create an account on cloudflare pages
  3. integrate forked nft-gallery to cloudflare pages
  4. add SENTRY_AUTH_TOKEN as env

send me a discord message if you need pairing

@prury
Copy link
Member

prury commented Aug 7, 2023

maybe @prury want to test also?

how to test:

1. fork nft-gallery

2. create an account on cloudflare pages

3. integrate forked nft-gallery to cloudflare pages

4. add `SENTRY_AUTH_TOKEN` as env

send me a discord message if you need pairing

yup! will need your assistance

@preschian
Copy link
Member

preschian commented Aug 8, 2023

oh, now, breaks on netlify deployment https://app.netlify.com/sites/koda-canary/deploys/64d1fb67f867ea0007170f88

error on the other platform can be easily fixed after retry the deployment

@preschian
Copy link
Member

Now, it is an intermittent error, and we need to retry the deployment if show up the error again. I don't know what the root cause is 🥲

It's time to move to Vite, I guess. Currently, we are still using webpack in nuxt-bridge

@preschian
Copy link
Member

I will remove SENTRY_AUTH_TOKEN in preview branch for now

@preschian
Copy link
Member

It would be good if someone could find the root cause cc @kodadot/internal-dev

For context: there are no changes from the Cloudflare pages dashboard, but somehow when trying to deploy it to production, it throws the error. first occurrence #6470 (comment)

@yangwao
Copy link
Member Author

yangwao commented Aug 9, 2023

I will remove SENTRY_AUTH_TOKEN in preview branch for now

Yes, please leave it w/o SENTRY token, I prefer working build than reporting Sentry from broken build 😄
I hope we'll figure out tbh, maybe some issue on our side.

Probably time to check on Vite too

@preschian
Copy link
Member

preschian commented Aug 10, 2023

Confusing part was it works well on my forked version https://main.nft-gallery-1hj.pages.dev/

wanna try to upload it through gh-actions? @yangwao
run pnpm generate on gh-actions, and then upload it using this https://github.com/cloudflare/pages-action

@preschian
Copy link
Member

wanna try to upload it through gh-actions? @yangwao run pnpm generate on gh-actions, and then upload it using this cloudflare/pages-action

oh nvm, it also error on github actions

image

@yangwao
Copy link
Member Author

yangwao commented Aug 11, 2023

wanna try to upload it through gh-actions? @yangwao
run pnpm generate on gh-actions, and then upload it using this cloudflare/pages-action

uh sounds pretty complicated, keep it simple 😄

@preschian
Copy link
Member

The Journey

Hi, I want to share my journey here after trying some stuff to validate the assumptions. Here are some assumptions that seem not valid

1. SENTRY_AUTH_TOKEN was the problem. Ref: #6470 (comment).

Last week, I thought that was the main problem. Because, in the previous week, the build worked well after we removed that from environment variables. Unfortunately, last night we faced the same error again, even though we pulled the env

You can see in the screenshot below that I only put PNPM_VERSION in the environment variables section. But the build still has an error in the "Build log" section.

screenshot fail

image

Then I just retried several times until it worked. You can see this in the screenshot below. Same env, same code, and then the build works

screenshot success

image

I already tried to remove sentry-related packages also, but it still fails. Here is the commit. Here is the gh-actions logs. Here is the PR.

2. Cloudflare Pages was the problem. Ref: #6518 (comment)

I thought that the error was only in the Cloudflare Pages. But, I discovered that it could also be an error on netlify, even locally.

error logs on netlify: https://app.netlify.com/sites/koda-canary/deploys/64d1fb67f867ea0007170f88

error logs on gh-actions: https://github.com/kodadot/nft-gallery/actions/runs/5830455843/job/15811865669

error logs on my local

Screenshot 2023-08-11 135903

The tricky part, the error was intermittent and did not correctly return the exit code. So, even though the build was incomplete, CI continued the process. If the error returns the exit code correctly, we can detect the mistake early in our gh-actions.

Last Assumptions

I think that our build steps are within the limits. I found that someone also tried to reduce the total generated files in nuxt generate. Ref: https://stackoverflow.com/q/71890697

Here is another attempt related to building steps

Moving forward to Nuxt3

I hope we can find a way to use Nuxt3 + Vite immediately. So far, I have only one option to use Nuxt3 #6429 right away. But, tbh, I want that POC for the last option because the most significant downside of my POC was that we needed to create a component from scratch.

Feel free to share if someone has a better alternative to migrate to Nuxt3.

@yangwao
Copy link
Member Author

yangwao commented Aug 11, 2023

I think that our build steps are within the limits.

We hit this because we are trying to process too many components at once or..? I haven't slept well today, so asking 😄

@vikiival
Copy link
Member

I haven't slept well today, so asking 😄

Imo what was mentioned in SO is that cloudlfare has limits for files

https://developers.cloudflare.com/pages/platform/limits/

and every component and async component is separated file + blog assets & so

@preschian
Copy link
Member

We hit this because we are trying to process too many components at once or..?

Something like that. between so heavy to process or too many files

I haven't slept well today, so asking 😄

😅😅😅

@preschian
Copy link
Member

I haven't slept well today, so asking 😄

Imo what was mentioned in SO is that cloudlfare has limits for files

developers.cloudflare.com/pages/platform/limits

this is also could be possible the problem for them in Stackoverflow case

@yangwao
Copy link
Member Author

yangwao commented Aug 12, 2023

and every component and async component is separated file + blog assets & so

There are limit 20k files, I usually see low as 6xx files being uploaded. Then it must be something else I guess?

@preschian
Copy link
Member

preschian commented Aug 12, 2023

Correct, I'm sure the error in our app is not related to limits on Cloudflare Pages. Because we have evidence that we can face the error on gh-actions, netlify, and even locally. So, I assume there is something related to building steps in our app.

For the person in Stackoverflow, it might be the issue is from limits on cf-pages, or I would say it might be identical with us also if they have under 20k files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
$$ ~51-150usd 🧙‍♀️ - bug-hunt A-maintenance A-vite p2 core functionality, or is affecting 60% of app
Projects
None yet
4 participants