If I have a NextjsSite and run a `yarn sst deploy`...
# sst
j
If I have a NextjsSite and run a
yarn sst deploy
then make no changes to anything and run
yarn sst deploy
again, it thinks the web app has changed and does an update. I assume that this is because a
deploy
executes a build and there must be something that is generated which changes every build even with no code changes? How can I prevent this? Is it a bug?
f
Hey @jamlen, it is expected. Next.js generate a unique id for each build. You can override this id to make sure it doesn’t change on rebuild https://nextjs.org/docs/api-reference/next.config.js/configuring-the-build-id
j
Thanks @Frank
Also @Frank as I've deployed that little demo, I want to remove it but running
yarn sst remove
errors with
Copy code
Stack jamlen-deploy-bug-WebPlatformStack
  Status: failed
  Error: Resource handler returned message: "Lambda was unable to delete arn:aws:lambda:us-east-1:1234567689:function:jamlen-deploy-bug-WebPlat-webnextjsMainFunctionEE1-Pa8KYMI60tVa:2 because it is a replicated function. Please see our documentation fo
r Deleting Lambda@Edge Functions and Replicas.
This is just a vanilla
Copy code
$ yarn create serverless-stack --use-yarn --language typescript deploy-bug
$ yarn create next-app --ts web
$ yarn add @sls-next/lambda-at-edge
$ yarn deploy
$ yarn remove
f
Yeah, NextjsSite uses Lambda@Edge. Edge functions are replicated to edge locations, and they take a while to remove.
If you wait for a couple of minutes and try removing it again, it should work.
That said, we have an open issue to work around this https://github.com/serverless-stack/serverless-stack/issues/835
k
@Frank How should we approach CI-CD of ephemeral stacks/stages that need to destroyed and as such destroy the lambda @ edge
f
Hey @Kuda Zhou, yeah, there isn’t a great solutions until this is fixed. Currently you’d either have to retry removing the stack after ie. 1hr; or set the removal policy for the edge function as RETAIN so the stack can be removed successfully, and thensetup a cron job that cleans up the functions.