Are there any know issues with the "aws-lambda" preset?
I 'am currently migrating an SPA with SSR to @tanstack/start. The app is deployed on AWS Lambda, so I was wondering if there are any known issues because of the warning.
18 Replies
frail-apricot•12mo ago
You mean the untested warning yes?
We haven't had the time to test it out or even check whether it works at all.
We just wanted to cover our bases.
harsh-harlequinOP•12mo ago
Ok, thnx. I will give an update here about the migration.
frail-apricot•12mo ago
Cool beans.
If its working, could probably take it out of the untested list.
harsh-harlequinOP•12mo ago
@Sean Cassiere As far as I can seen now, the only thing that is not working are server functions. Somehow the files from .vinxi/build/server/_server/.mjs are not bundled into the .output folder.
If I look in runtime.mjs, server function code has been embedded, but a request from the client tries to resolve
c_oku6zv.mjs
and cannot find it.
const mod_0_3 = /#PURE/ Object.freeze({
proto: null,
$$function0: y,
Route: F,
getCountryCode: f,
});
const chunks = {};
chunks["c_oku6zv.mjs"] = mod_0_3;
My post build step (workaround) is now `cp .vinxi/build/server/_server/.mjs .output/server/chunks/build`, but this will fail if there are name clashes.
Wouldn't it be better if the output folder has seperate folders for client and server artifacts, i.e. use different base folders in the output for each router? (Don't know if this a @tanstack/start, vinxi or nitro issue)frail-apricot•12mo ago
That's a good point. Generally, this should resolve if its working on the other deployment presets, so I'd look into Vinxi and Nitro. Perhaps, see if you are able to take one of their server-functions examples and see if that can be deployed?
I'll unfortunately not be able to look into this for a couple weeks at the least. Sorry for the late response 😅.
Not to mention AWS deactivate my account over a year ago and absolutely do not budge to opening closed accounts 🤷🏼♂️
harsh-harlequinOP•12mo ago
I discovered the issue and is was caching. CloudFront responded with an older page that used an older serverFnId. The workaround above is not needed at all.
Created a small PR that fixes the build when setting the routers > client > base option (see https://github.com/TanStack/router/pull/2437)
vicious-gold•12mo ago
please check the e2e test failure
harsh-harlequinOP•12mo ago
I don't think it is a problem with the fix. The errors we get are "net::ERR_CONNECTION_REFUSED " errors. When I run the tests in the failed package they succeed. Also when I run
nx run-many --target=test:e2e --parallel=false
all test succeed. But when I run nx run-many --target=test:e2e
, we get the "net::ERR_CONNECTION_REFUSED " errors.vicious-gold•12mo ago
I retriggered the build job, let's wait
harsh-harlequinOP•11mo ago
Two weeks ago we went live with @tanstack/start and the aws-lambda preset. So far everything looks good.
vicious-gold•11mo ago
can you share the site?
harsh-harlequinOP•11mo ago
The site we developed for one of our customers and migrated to @tanstack/start is https://www.weer.nl one of larger weather info websites for The Netherlands
Weer.nl
Weer.nl - Alles over het weer in Nederland in één blik
Weer.nl is dé actuele weersite van Nederland met gedetailleerde neerslagradar, plaatsverwachtingen en het laatste weernieuws.
absent-sapphire•7mo ago
I am currently evaluating start using the aws-lambda preset too. While I managed to deploy to cloudfront and lambda exposed via API Gateway with AWS cdk successfully I struggle to understand how to wire up the connection to the lambda server side. @Robin do you have a hint how you managed to connect these pieces?
harsh-harlequinOP•7mo ago
@phoefflin We take the lambda code from the folder produced by nitro
.output/server
in the CDK like this:
We deploy the files/folders from .output/public
to S3 and create behaviours for the folders and files in CloudFront. The default behaviour points to an apigateway that proxies everything to the lambda.
I hope this helpsabsent-sapphire•7mo ago
@Robin thanks this already helps. Is it possible to give a small example snippet for the behaviours in cloudfront? Thanks!
harsh-harlequinOP•7mo ago
@phoefflin there is no magic here, it is just standard CDK stuff. You read the public folder content with i.e. readdirSync and create additional behaviours for files and folders
/filename
for files and /foldername/*
for folders. See CDK docs for CloudFront https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront-readme.htmlaws-cdk-lib.aws_cloudfront module · AWS CDK
Language | Package
absent-sapphire•7mo ago
Thanks, will check this
rival-black•3mo ago
I'm building a docker image with CDK bundling server and public just to test things out.
I may be wrong - but there should be a setting for either tan/nitro to serve public assets from the ./public folder, right?