-
-
Notifications
You must be signed in to change notification settings - Fork 458
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
Tracking ISR issues #1098
Comments
@kirkness the ISR tests have been fairly flaky (mostly failing but sometimes 1/3 or 2/3 pass), if you have a chance please take a look otherwise I can check it out later on the weekend: https://github.com/serverless-nextjs/serverless-next.js/actions/runs/863012949 |
Hi @dphang, keen to have a look at this, however, I won't be able to get much time on it until early next week, likely Tuesday. |
Related: #1099 |
No worries, yeah it would be good to add more test coverage. The last few runs seem to not be flaky, though. |
Not sure if I should open an issue about this or write straight to this thread... We are getting the following debug log information when trying to deploy the Our deploy script uses an existing serverless state made with previous deployment. That successfully deployed version uses SSR only, otherwise the configuration and component version are exactly the same. We are just trying to switch to use ISR. Any help with this would be appreciated and thanks for the great work you have been doing for the ISR support!
|
I'm having the same problem here and I have a theory about the cause (It's really just a shot in the dark). I think the errors occurs at // triggerStaticRegeneration.ts
await sqs.send(
new SendMessageCommand({
QueueUrl: `https://sqs.${region}.amazonaws.com/${bucketName}.fifo`,
...
})
);
export const s3BucketNameFromEventRequest = (
request: AWSLambda.CloudFrontRequest
): string | undefined => {
const { region, domainName } = request.origin?.s3 || {};
return domainName?.replace(`.s3.${region}.amazonaws.com`, "");
}; Looking at the the docs for AWSLambda.CloudFrontRequest the s3 origin looks like this: This will result in So QueueUrl would be That QueueUrl would be incorrect in my case. The created SQS has this url: ConclusionI suspect that the account id |
Some issues I have come across implementing the ISR functionality:
|
I think its this line which is run on deployment:
I'll put in a fix for this. |
Revalidate not working as expected (I think). Running 1.20.0-alpha.18 in eu-west-2, the request sequence/behaviour is as follows:
nth request is when Revalidate / s-maxage is reached. Below is the small example I ran the text on:
Also having issues on other more complex pages where it's a cache miss every time. Any thoughts? |
@mikejcooper Unfortunately I'm not really familiar with apollo client, is it a problem without it as well? |
Great work on this so far guys. I have some questions. Is revalidate supposed to be functional with
Am i missing any specific configurations that is needed? |
Please post the logs (503 is very generic and doesn't tell anything about the actual issue). Without knowing anything, I'm gonna guess there could be a permissions issue |
Hi, I'm having the same issue, the error shows on the browser and there are no logs, or at least I couldn't find any. In my case, I'm doing the deployment on a github action, here is the serverless.yml file: name: api-hub-web
nextApp:
component: "@sls-next/[email protected]"
inputs:
bucketName: web-dev-s3
description: '*lambda-type*@Edge for dev-api-hub-web'
name:
defaultLambda: web-dev-lambda
apiLambda: web-dev-lambda
publicDirectoryCache: false
runtime:
defaultLambda: 'nodejs12.x'
apiLambda: 'nodejs12.x'
logLambdaExecutionTimes: true
minifyHandlers: true
memory: 2048
timeout: 30
policy: 'arn:aws:iam::<acount>:policy/next-lambdas-execution-policy' The deployment permissions are the same as https://github.com/serverless-nextjs/serverless-next.js#aws-permissions-for-deployment and the lambda policy is the following: {
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:*",
"logs:CreateLogStream",
"sqs:*",
"logs:CreateLogGroup",
"logs:PutLogEvents"
],
"Resource": "*"
}
]
} I'm using |
In testing ISR with the https://github.com/dapperlabs/nextjs-isr-testing repo, I also am seeing 503 errors on retrieving JSON data files. I found this in the default lambda logs:
|
Hey @teban3010, make sure to switch to the region in the console that you are viewing the failing page from, a few more deets here: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-cloudwatch-metrics-logging.html#lambda-cloudwatch-logs |
@kirkness thanks for that, I have the same error as @adamelmore on the lambdas ERROR Invoke Error
{
"errorType": "TypeError",
"errorMessage": "n.lib.decodeHTML is not a function",
"$metadata": {
"attempts": 1,
"totalRetryDelay": 0
},
"stack": [
"TypeError: n.lib.decodeHTML is not a function",
" at Object.tagValueProcessor (/var/task/index-b8afa7fd.js:1:59241)",
" at y (/var/task/serdePlugin-45449631.js:1:7924)",
" at Object.h.getTraversalObj (/var/task/serdePlugin-45449631.js:1:9674)",
" at Object.t.parse (/var/task/serdePlugin-45449631.js:1:21540)",
" at /var/task/index-b8afa7fd.js:1:59096",
" at processTicksAndRejections (internal/process/task_queues.js:97:5)"
]
} UPDATE: This happens on an update of a deployment that uses a previous version of the component and on a new one as well. |
If you check affected dist files, it looks like it's trying to call a non-existent function: index-b8afa7fd.js var parseBody = function (streamBody, context) {
return collectBodyString(streamBody, context).then(function (encoded) {
if (encoded.length) {
var parsedObj = serdePlugin.parser.parse(encoded, {
attributeNamePrefix: "",
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: function (val, tagName) { return (val.trim() === "" ? "" : serdePlugin.lib.decodeHTML(val)); },
});
var textNodeName = "#text";
var key = Object.keys(parsedObj)[0];
var parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return serdePlugin.getValueFromTextNode(parsedObjToReturn);
}
return {};
});
}; When I checked Not sure why it's not being bundled correctly by Rollup? |
Seems there might be a problem with Ref PR: rollup/plugins#658 It can't be easily caught in unit tests (Rollup bundling issue), but possibly should add an e2e test for this? cc: @kirkness. Meanwhile I will downgrade to 18.1.0, which I tested and it bundles correctly. And also exclude it from dependabot updates. |
The above fix is already published, please try it out and see if it works for you. |
I've tried out, it works at first but then I receive the same error on the default lambda. The only difference is that now if I press F5, some times I see the page and some times I have a 503 error. On the network tab, I see a lot of 503 of the other pages json. The other thing is that the page is not being updated after the revalidate time. ERROR Invoke Error
{
"errorType": "TypeError",
"errorMessage": "n.lib.decodeHTML is not a function",
"$metadata": {
"attempts": 1,
"totalRetryDelay": 0
},
"stack": [
"TypeError: n.lib.decodeHTML is not a function",
" at Object.tagValueProcessor (/var/task/index-b8afa7fd.js:1:59241)",
" at y (/var/task/serdePlugin-45449631.js:1:7924)",
" at Object.h.getTraversalObj (/var/task/serdePlugin-45449631.js:1:9674)",
" at Object.t.parse (/var/task/serdePlugin-45449631.js:1:21540)",
" at /var/task/index-b8afa7fd.js:1:59096",
" at processTicksAndRejections (internal/process/task_queues.js:97:5)"
]
} |
Based on the hash on your latest log of the affected file:
Please check if you had updated properly to the latest alpha version, if you specify the latest version exactly in serverless.yml file, I think it should have no problems (not sure if you use just alpha tag from npm, there could potentially be caching problems?). The latest version is 1.20.0-alpha.25, you can always find in npm: https://www.npmjs.com/package/@sls-next/serverless-component/v/1.20.0-alpha.25. From the version tab I see 0 downloads so far of the latest version (either npm is not updated so fast or there are really no downloads yet). Also it does take some time for function updates to propagate? |
You are right, I used version 24. Now it's not returning 503, but it's not doing the ISR, I added a date property with ERROR Invoke Error
{
"errorType": "Error",
"errorMessage": "Cannot find module './pages/.js'\nRequire stack:\n- /var/task/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
"code": "MODULE_NOT_FOUND",
"requireStack": [
"/var/task/index.js",
"/var/runtime/UserFunction.js",
"/var/runtime/index.js"
],
"stack": [
"Error: Cannot find module './pages/.js'",
"Require stack:",
"- /var/task/index.js",
"- /var/runtime/UserFunction.js",
"- /var/runtime/index.js",
" at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)",
" at Function.Module._load (internal/modules/cjs/loader.js:667:27)",
" at Module.require (internal/modules/cjs/loader.js:887:19)",
" at require (internal/modules/cjs/helpers.js:74:18)",
" at /var/task/index.js:1:4565",
" at Array.map (<anonymous>)",
" at Runtime.exports.handler (/var/task/index.js:1:4409)",
" at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"
]
} |
Not sure which line is failing but it's strange to be requiring a pages/.js file, not sure why it's coming empty. Could you please unminify the Lambda so it's easier to understand which line is failing in the SQS lambda (regeneration). And also post how your pages directory structure looks like, manifests etc if possible. Guessing it's because of the SQS-triggered lambda just tries to require the page path passed from the SQS message data after it gets triggered here: serverless-next.js/packages/libs/lambda-at-edge/src/default-handler.ts Lines 287 to 292 in 135e006
Sending event: serverless-next.js/packages/libs/lambda-at-edge/src/lib/triggerStaticRegeneration.ts Lines 42 to 58 in 135e006
Parsing the event and requiring page: serverless-next.js/packages/libs/lambda-at-edge/src/regeneration-handler.ts Lines 13 to 23 in 135e006
I wonder if there's a special character that is not being passed properly through SQS message body? |
I believe that I remove the minify from the serverless.yml file, but I see the exact same error. This is my serverless.yml file name: web
nextApp:
component: "@sls-next/[email protected]"
inputs:
bucketName: web-s3
description: '*lambda-type*@Edge for web'
name:
defaultLambda: web-default-lambda
apiLambda: web-api-lambda
imageLambda: web-image-lambda
publicDirectoryCache: false
runtime:
defaultLambda: 'nodejs12.x'
apiLambda: 'nodejs12.x'
logLambdaExecutionTimes: true
# minifyHandlers: true
memory: 2048
timeout: 30
policy: 'arn:aws:iam::599903031295:policy/next-lambdas-execution-policy' And this is my pages directory structure:
I'm not sure where can I get the manifest. |
@teban3010 we need which line it is failing at. Manifests are the JSON files generated in
If you could provide some repro step as well (or a repo) then I can also debug myself. Otherwise it's hard to guess where is failing. |
Sorry, I didn't get that at first. I'm doing all the deployment using a github action, so I didn't have access to those files because were created on the server. Now, I did the deployment from my machine, and got those files. Unfortunately, I cannot provide access to the repository, but I will try to put something in place so you can test it out. For the deployment, I'm just running The
Regeneration-lambda manifest: {
"buildId": "VYqAiP3KsZSxRrAqToc5l",
"pages": {
"dynamic": [],
"ssr": {
"dynamic": {},
"nonDynamic": {
"/account": "pages/account.js",
"/contact": "pages/contact.js",
"/": "pages/index.js",
"/products": "pages/products.js",
"/_error": "pages/_error.js"
}
},
"html": { "dynamic": {}, "nonDynamic": { "/404": "pages/404.html" } },
"ssg": {
"dynamic": {},
"nonDynamic": {
"/contact": { "initialRevalidateSeconds": 10, "srcRoute": null },
"/products": { "initialRevalidateSeconds": 10, "srcRoute": null },
"/": { "initialRevalidateSeconds": 10, "srcRoute": null }
}
}
},
"publicFiles": {
"/android-chrome-192x192.png": "android-chrome-192x192.png",
"/android-chrome-512x512.png": "android-chrome-512x512.png",
"/apple-touch-icon.png": "apple-touch-icon.png",
"/email/hub_1.png": "email/hub_1.png",
"/email/hub_logo_blue.png": "email/hub_logo_blue.png",
"/email/logo_white.png": "email/logo_white.png",
"/favicon-16x16.png": "favicon-16x16.png",
"/favicon-32x32.png": "favicon-32x32.png",
"/favicon.ico": "favicon.ico",
"/icons/ask.svg": "icons/ask.svg",
"/icons/business.svg": "icons/business.svg",
"/icons/clipboard.svg": "icons/clipboard.svg",
"/icons/contact.svg": "icons/contact.svg",
"/icons/developer.svg": "icons/developer.svg",
"/icons/status.svg": "icons/status.svg",
"/icons/word-balloon.svg": "icons/word-balloon.svg",
"/illustrations/building.svg": "illustrations/building.svg",
"/illustrations/home_page_1.png": "illustrations/home_page_1.png",
"/illustrations/home_page_2.png": "illustrations/home_page_2.png",
"/illustrations/news.svg": "illustrations/news.svg",
"/illustrations/supplier.svg": "illustrations/supplier.svg",
"/logo-blue.png": "logo-blue.png",
"/logo.svg": "logo.svg",
"/site.webmanifest": "site.webmanifest"
},
"trailingSlash": false,
"domainRedirects": {},
"enableHTTPCompression": false,
"logLambdaExecutionTimes": true
} Default-lambda manifest: {
"buildId": "VYqAiP3KsZSxRrAqToc5l",
"pages": {
"dynamic": [],
"ssr": {
"dynamic": {},
"nonDynamic": {
"/account": "pages/account.js",
"/contact": "pages/contact.js",
"/": "pages/index.js",
"/products": "pages/products.js",
"/_error": "pages/_error.js"
}
},
"html": { "dynamic": {}, "nonDynamic": { "/404": "pages/404.html" } },
"ssg": {
"dynamic": {},
"nonDynamic": {
"/contact": { "initialRevalidateSeconds": 10, "srcRoute": null },
"/products": { "initialRevalidateSeconds": 10, "srcRoute": null },
"/": { "initialRevalidateSeconds": 10, "srcRoute": null }
}
}
},
"publicFiles": {
"/android-chrome-192x192.png": "android-chrome-192x192.png",
"/android-chrome-512x512.png": "android-chrome-512x512.png",
"/apple-touch-icon.png": "apple-touch-icon.png",
"/email/hub_1.png": "email/hub_1.png",
"/email/hub_logo_blue.png": "email/hub_logo_blue.png",
"/email/logo_white.png": "email/logo_white.png",
"/favicon-16x16.png": "favicon-16x16.png",
"/favicon-32x32.png": "favicon-32x32.png",
"/favicon.ico": "favicon.ico",
"/icons/ask.svg": "icons/ask.svg",
"/icons/business.svg": "icons/business.svg",
"/icons/clipboard.svg": "icons/clipboard.svg",
"/icons/contact.svg": "icons/contact.svg",
"/icons/developer.svg": "icons/developer.svg",
"/icons/status.svg": "icons/status.svg",
"/icons/word-balloon.svg": "icons/word-balloon.svg",
"/illustrations/building.svg": "illustrations/building.svg",
"/illustrations/home_page_1.png": "illustrations/home_page_1.png",
"/illustrations/home_page_2.png": "illustrations/home_page_2.png",
"/illustrations/news.svg": "illustrations/news.svg",
"/illustrations/supplier.svg": "illustrations/supplier.svg",
"/logo-blue.png": "logo-blue.png",
"/logo.svg": "logo.svg",
"/site.webmanifest": "site.webmanifest"
},
"trailingSlash": false,
"domainRedirects": {},
"enableHTTPCompression": false,
"logLambdaExecutionTimes": true
} |
I've made a deployment using this repo https://github.com/dapperlabs/nextjs-isr-testing, just add static props on index and adding the same serverless.yml file that I already have, and it worked. As I'm based on Argentina I have some delay on the time I believe that is due to replication on Cloudfront. @dphang yes, the error is the same, is it possible that there is something old on the deployment? how can i completely remove the deployment, I don't see any stack created so I'm not sure how to delete everything at one, so I can redeploy it from scratch and check if that is the actual issue. Is
That's good!! |
Thanks, will take a look later this weekend |
Have already been using admin roles so SQS permissions should not be problem. But never able to get ISR working :( Can someone please provide a simple list of setups to try ISR? I can only ctrl-f the readme.md for "incremental" and don't know if it needs extra configuration... Also, is it expected to be flanky right now? I was trying to do ISR but it cant revalidate, then I tried gSSP but it always gives the default locale when route change. Now I am forced to use gSP without revalidate and use a CI/CD to rebuild every hour... |
Just as an update. I've been deploying with the latest version for the last days and also removed the custom policy that I have. Now I see the following behaviour:
|
@teban3010 sorry I hadn't had much luck when taking a look yet. Are you able to build from source and add some logging statements, it might be helpful to understand where the code is failing. |
I'm using a custom handler defined in my serverless config file that I have in a file called custom.js in the nextjs root directory. Example, myNextApplication: However when the "Next.js Regeneration Lambda" deploys it doesn't seem to copy the custom handler code over (which is fine by me). The problem is that the Regeneration Lambda seems to set the custom handler name into the lambda definition instead of "index.handler". ISR seems to work if I update the Regeneration Lambda handler to "index.handler" instead of the "custom.handler" that I had before. Not sure if this is a bug but it seems suspicious. Thanks! |
@dphang I previously got some errors related to permissions but I'm currently stuck at the same point as @teban3010. And I might have some time to build from source and add some logs to it, but I'm not familiar with the project at all. Can you give me some pointers so I can try to help you guys out? |
@dphang Firstly, thanks for all the work on this repo, it's working great for our team! I'm having trouble with ISR, the getStaticProps is acting like getServerSideProps. The example code below is my index.ts file adapted from your original PR with an added sleep for 5s. Each request to index takes ~5.3s. I was expecting a cached version served back to the client. What am I doing wrong here?
Using 3.2.0-alpha.16 |
@igormartimiano yes, you can edit the code in default-handler (lambda-at-edge package) and look at CONTRIBUTING.md for some help as well. The trigger of the static regeneration from default lambda is here: serverless-next.js/packages/libs/lambda-at-edge/src/lib/triggerStaticRegeneration.ts Line 12 in 3f75647
@mikejcooper sure I can take a look this week, if you have time you can also try to debug following above steps to see the exact behavior cc: @kirkness if you have any ideas as well. |
I'm encountering similar same issues with pages not being refreshed after the set I've checked logs but couldn't find any errors. I've noticed that only the main homepage, so https://www.voteswiper.org/tr is refreshed. The whole source code is published here: https://github.com/MOVACT/voteswiper-web/ As far as I see, I'm not doing anything out of the ordinary. Any ideas on how to debug this further? Edit: I've noticed that every request is a Miss from cloudfront and the cache-control header is always |
I was incorrect. I've debugged so many things that I wrongly assumed this. The actual issue for me was providing paths in |
I get "NotImplemented" error on Next 11. It is fixed right after I downgraded Next to 10.2.3. |
I don't have much to add to this, other than ISR stopped working for me on a recent deploy. One of the new features I added was using next.js's i18n localization. On a bit of a whim, I decided to remove it and redeploy, and now ISR is working again. @dphang - not sure if that information helps to narrow this down at all. Maybe something to do with the Accept Language header being part of the CloudFront cache key when localization is enabled? Or something to do with the localized subpathing (though I only had a single I noticed all my |
Something strange is happening in ISR, sometime it properly follow the revalidate timings and regenerate the page but sometime event after 10-20 refreshes and waiting for 30 sec it doesn't do anythings, it returns the same page. Sometime it works fine, sometime it doesn't I am getting always cache-control: public, max-age=0, s-maxage=0, must-revalidate as header when it doesn't work, Is something wrong with SQS or cloudfront @dphang Can you please help |
@WarcraftYax hm yes there is not good e2e test coverage for i18n locales yet, it might be that the path is not translated correctly to hit the regeneration lambda (and save the new page), are there any errors you can see in the regeneration lambda? Can you maybe open a new issue with the same details so it's easier to track. @yogeshydvme maybe can you open a new issue with more details like page you are trying to hit, any error logs, etc (both in the default and regeneration lambdas). I'll close this soon; I think this issue has gotten quite large so opening separate issues will help in tracking it better. |
With the latest v3.3.0-alpha.5 and Nextjs 11.1.0 my ISR issues have been resolved. I removed all the resources created by AWS and removed the directories created by serverless-next, and redeployed. Thank you for the good work on this project. |
ive just tried again on 3.3.0-alpha.5 and nextjs 11.1.1 and am receiving this error on my regeneration lambda:
Edit: Looks like nextjs 11.1.1 has changed |
@danjiro yes I just tried to fix here: #1611, hopefully it solves it. I think the problem is Next.js keeps changing the implementation - but I updated it to the latest and also added a fallback to use the page's renderReqToHtml (without renderMode specified, which seems to render HTML string regardless of version). |
Closing this issue since I believe most of the initial issues should have been resolved (or if not, have asked to create a new issue), going forward please create new issues so it's easier to separate and track. Thanks! |
thanks so much for fixing this! |
Hello! quick question. Can anyone talk a little bit about the aws costs of running ISR? I have one page that would need to be regenerated every 10 seconds. I'm not sure how things work under the hood but I assume there are a handful of services that will rerun every 10 seconds and therefore increasing cost? Thanks! |
Just creating this to track any bugs or issues with the newly-released Incremental Static Regeneration feature -
The text was updated successfully, but these errors were encountered: