Closed endigo9740 closed 2 years ago
Hi @endigo9740 Thank-you for taking an interest in my project. It seems since the last release of the adapter and now, the svelte team have some changes to the way there Fetch polyfill works, to get around this i have just published a new package, v0.5.1 that moves to using node-fetch to provide the fetch shims. I have tested this on your repo and the build looks to have passed.
I have also done a full redeploy on my test site and that looks to be working as well, could you let me know if this has fixed your issue?
Thanks James
James, thanks for the quick turnaround on this! I can confirm the same results here. This should help us progress on our side.
FYI I'm also seeing the "dynamic import" warning per your screenshot. Is that anything we should worry about? Strangely enough I don't even see an index located at build/index.js
as indicated by the message
Thanks again! Chris
@endigo9740 I see that error too on my test site and as far as i can see it runs as expected without issues.
That file is a build artifact and is cleared down one the build is finished, hence why you can't find it.
Gotcha. That's what I assumed but wasn't sure.
So far we're making progress. We attempted our first deployment this morning, but are unfortunately seeing a couple issues. Not sure if you can help debug this, but here's going on...
The build succeeds, however there appears to be a problem with the serverless script. It created some of the assets on AWS, but fails on an S3 error. It says our bucket dev-sveltekit-app-static-assets
already exists, but it does not.
Users-Mac-mini:bb-svelte-example user$ sls deploy --aws-profile brainandbones
Running "serverless" from node_modules
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Updated Lambda assume role policy to allow Lambda@Edge to assume the role
Serverless: Added "origin-request" Lambda@Edge association for version "(scrubbed)" to distribution "WebsiteDistribution"
Serverless: Creating Stack...
Serverless: Checking Stack create progress...
........
Serverless: Stack create finished...
Serverless: Ensuring that deployment bucket exists
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service svelte.zip file to S3 (68.81 kB)...
Serverless: Uploading service cfLambda.zip file to S3 (68.81 kB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
............
Serverless: Operation failed!
Serverless: View the full error output: https://us-east-2.console.aws.amazon.com/cloudformation/home?region=us-east-2#/stack/detail?stackId=...(scrubbing this)
Serverless Error ----------------------------------------
An error occurred: StaticAssets - dev-sveltekit-app-static-assets already exists.
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
Operating System: darwin
Node Version: 14.17.6
Framework Version: 2.72.3 (local)
Plugin Version: 5.5.4
SDK Version: 4.3.1
Components Version: 3.18.2
Users-Mac-mini:bb-svelte-example user$
FYI, the only modification we made to the serverless script itself was switching the region from us-east-1
to us-east-2
.
We also noticed that the sls deploy
seems to have produced multiple entries for the dev-sveltekit-app-static-assets S3 bucket in the serverless-state.json file
.
We're new to the Serverless Framework and unsure if this is normal. Perhaps this is intended as a history file?
Note I pushed the adapter dependency bump to the Github repo shared in my original post if you want to test directly again.
Hi @endigo9740, S3 bucket names are global as per Amazons docs
An Amazon S3 bucket name is globally unique, and the namespace is shared by all AWS accounts. This means that after a bucket is created, the name of that bucket cannot be used by another AWS account in any AWS Region until the bucket is deleted.
My guess is that bucket name has already been taken somewhere else, by someone else. You can change the name of your bucket by renaming the service to something more unique, the service name should be the top line of your serverless.yml
service: 'sveltekit-app'
Furthermore, it looks like you are trying to deploy to us-east-2. Unfortunately, You have to deploy to us-east-1 if you want to use the provided serverless.yml file. This is because lambda at edge functions have to be deployed in us-east-1 and as far as I can see there is no way to have a cloud formation stack deploy resources to 2 different regions.
You could very well have 2 different stacks created by two different serverless.yml files one deploying your main app, S3 bucket and cloudfront to whatever region you want and the other deploying the edge lambda to us-east-1 and attaching it to the cloudfront distribution. I decided not include this setup as part of the provided Infra as code to help get people going as fast as possible.
James, seriously thank you for all the help here. Both responses make total sense. We were not aware of the globally unique names. We were aware of some AWS services being region locked, but not specifically that this would be.
Also, please let me know if you have a Patreon, Github tips, or similar available! Me and my company plan to utilize your adapter for a number of applications going forward and I would love to help provide some support your way. You know, other creating issues like this and asking a ton of questions! :)
Thanks again, Chris
Sorry but we've run into one more road bump. We've updating per your guidance above, but we've experience this error:
An error occurred: StaticAssets - A conflicting conditional operation is currently in progress against this resource. Please try again. (Service: Amazon S3; Status Code: 409; Error Code: OperationAborted; Request ID: BDEG9CGY1B9PTHMC; S3 Extended Request ID: 0010mFSbN/+/HdMMUBiI4Hdo6+c99Nl8QaexHtLEsNKgCjd6qQaUOqGeWYeBND9aeSzlZwTxC1M=; Proxy: null).
It sounds like a conflict between two CloudFormation processes that Serverless Framework has triggered. Not sure if that's anything you can help resolve, but just wanted to share just in case!
Users-Mac-mini:bb-svelte-example user$ sls deploy --aws-profile brainandbones
Running "serverless" from node_modules
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Updated Lambda assume role policy to allow Lambda@Edge to assume the role
Serverless: Added "origin-request" Lambda@Edge association for version "(scrubbed)" to distribution "WebsiteDistribution"
Serverless: Creating Stack...
Serverless: Checking Stack create progress...
........
Serverless: Stack create finished...
Serverless: Ensuring that deployment bucket exists
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service svelte.zip file to S3 (68.81 kB)...
Serverless: Uploading service cfLambda.zip file to S3 (68.81 kB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
..............................................
Serverless: Operation failed!
Serverless: View the full error output: https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stack/detail?(scrubbed)
Serverless Error ----------------------------------------
An error occurred: StaticAssets - A conflicting conditional operation is currently in progress against this resource. Please try again. (Service: Amazon S3; Status Code: 409; Error Code: OperationAborted; Request ID: BDEG9CGY1B9PTHMC; S3 Extended Request ID: 0010mFSbN/+/HdMMUBiI4Hdo6+c99Nl8QaexHtLEsNKgCjd6qQaUOqGeWYeBND9aeSzlZwTxC1M=; Proxy: null).
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
Operating System: darwin
Node Version: 14.17.6
Framework Version: 2.72.3 (local)
Plugin Version: 5.5.4
SDK Version: 4.3.1
Components Version: 3.18.2
Thanks for the offer of @endigo9740 support, but i'm happy just doing this a hobby outside of my full time dev job. I built this mainly because I wanted it, buts its great other people can use it too.
With regards for using sveltekit for anything commercial, Id maybe give it a bit longer to bake, they are still making breaking changes several times a month, not just to the adapter API but to other key bits of the framework as well, iv had to refactor my small test site to keep it working with the latest version of the framework.
Iv encountered this error before, was it possible that a bucket with that name existed before, and you recently deleted it, Iv just deployed the example svelte app from scratch and have not seen this issue, and when I have seen it in the past, it's always been because i've recently deleted a bucket with the same name
Well I appreciate the help all the same.
I agree with your sentiment. We're testing the waters right now with a smaller scale app. Seeing what does and does not work. Then we'll make a decision for how we want to proceed long term. We've had great success building a SvelteKit app for production using the official static site adapter, built in "SPA mode", hosted using S3+Cloudfront. We were just wanting to kick the tires on SSR though.
Per the error, we had actually planned to give it some time and try again in case it was something like that. Ok, that is helpful. We'll probably give this a bit more time then look at alternative solutions. I think you've more than satisfied the original issue raised, so I'm going to go ahead and close this out. Thanks again for the help!
Hello, first off thanks for your work on this adapter! However, I wanted to bring the following issue to your attention.
Steps to reproduce:
I've shared the repo publicly if you want to pull and test directly: https://github.com/Brain-Bones/bb-svelte-example
The issue: When we
npm run build
we receive the following errors and are unsure how to proceed.