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

Possible to request update to prod-packager-packages by API call when we publish new dependencies to npm? #1246

Open
stevelewis99 opened this issue Jan 29, 2025 · 3 comments

Comments

@stevelewis99
Copy link

stevelewis99 commented Jan 29, 2025

We are using sandpack to showcase what is possible with our SDK, and it's working great.

Each time we update the site to point to the new release of our packages, there can be a few minutes delay on first load since the packages are not in your cache already. Since I am testing it first, for my region it's ok by the time we publish.

Other users in different geos experience the same delay when they access our site, and if possible it would be ideal if we can do something to get ahead before pushing site updates.

Looking at browser traffic, it seems there is a lambda function called when the package is not available, to initiate the cache population (I think) - but since this function is different per AWS region we have that regional problem.

@CompuIves If you can think of any workaround (I don't mind making some manual GET requests, if you can share the endpoints for each region, since I only have eu-west-1 now) I would be very grateful!

edit: I should add, I'm making some assumptions here, that there are different regions used, based on reports from my colleagues. I may be wrong

@CompuIves
Copy link
Member

Hey! Yes, you're completely right. What we essentially do is:

  • The client checks if the package is already available in an S3 bucket that's fronted by Cloudflare
  • If it's not available, it will call a Lambda function that installs the package, extracts relevant files and then puts it in the S3 bucket

I think, for your use case, it would be sufficient to directly call the lambda function on publish. As soon as the package is in S3, we will bypass the lamdba function altogether. The API of the lambda function is very stable at this point, it has been untouched for a couple of years! 😂

@stevelewis99
Copy link
Author

stevelewis99 commented Jan 29, 2025

@CompuIves Thank you, I will try this!

So to confirm - there is only one function to call (aiwi8rnkp5.execute-api.eu-west-1.xxxxx) and there are no other/different URLs needed for different regions, is that right?

I will try this on our next release and see if it works well, if so we might be able to add it as part of our release process (only every 2 weeks, not every hour don't worry 😂 )

@CompuIves
Copy link
Member

Yep, just that URL is enough! The Lambda runs in eu-west-1, and then it's stored in an S3 bucket that's fronted by a CDN that is global.

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

2 participants