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

503 Errors - The request could not be satisfied #222

Closed
ytwguru opened this issue Oct 30, 2019 · 15 comments
Closed

503 Errors - The request could not be satisfied #222

ytwguru opened this issue Oct 30, 2019 · 15 comments

Comments

@ytwguru
Copy link

ytwguru commented Oct 30, 2019

Describe the bug
We get irregular 503 errors for dynamic and static pages.

Updated
These seem to happen when the lambda requires more than 10 seconds to run

Expected behavior
After reloading the page, we see

503 ERROR

The request could not be satisfied.

The Lambda function associated with the CloudFront distribution is invalid or doesn't have the required permissions. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.

Generated by cloudfront (CloudFront)

@ytwguru ytwguru closed this as completed Oct 31, 2019
@MBach
Copy link

MBach commented Nov 4, 2019

Hi @ytwguru

Actually, I have the same problem. I don't know how to solve it, can you explain why you closed this issue?

@ytwguru
Copy link
Author

ytwguru commented Nov 4, 2019

@MBach. I still have the same problem, and it occurs irregularly. The issue was discussed here and I didn't want to create a duplicated issue.

I am still troubleshooting and reviewing the AWS CloudWatch Logs, but I can post an update or a PR if I get a solution.

@danielcondemarin
Copy link
Contributor

@ytwguru What have you found in your CloudWatch logs? I'm keen on getting to the bottom of any 503 errors.

@ytwguru
Copy link
Author

ytwguru commented Nov 8, 2019

@danielcondemarin My intermittent errors are with the graphql server.

"errorType": "Runtime.UnhandledPromiseRejection"
"errorMessage": "Error: Network error: request to https://****.com/graphql failed, reason: Client network socket disconnected before secure TLS connection was established"

Seems like some configuration of with next and apollo.

@mertyildiran
Copy link
Contributor

mertyildiran commented May 4, 2020

@danielcondemarin hi, I would like to resurrect this issue because I'm getting the exact same error:

Screenshot_20200504_180019

Though I couldn't really track the Request ID, I guess it's caused by this error in my case:

{
    "errorType": "Error",
    "errorMessage": "Cannot find module './pages/article/[...slug].js'",
    "code": "MODULE_NOT_FOUND",
    "stack": [
        "Error: Cannot find module './pages/article/[...slug].js'",
        "    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)",
        "    at Function.Module._load (internal/modules/cjs/loader.js:562:25)",
        "    at Module.require (internal/modules/cjs/loader.js:692:17)",
        "    at require (internal/modules/cjs/helpers.js:25:18)",
        "    at /var/task/index.js:59:18",
        "    at Generator.next (<anonymous>)",
        "    at /var/task/index.js:8:71",
        "    at new Promise (<anonymous>)",
        "    at __awaiter (/var/task/index.js:4:12)",
        "    at Runtime.exports.handler (/var/task/index.js:36:30)"
    ]
}

and a screenshot of the logs might be more meaningful:

Screenshot_20200504_224411

The thighs I observed are:

  • Firstly, even though I used only getStaticProps() and getStaticPaths(), the Static Site Generation (SSG) does not take place because the latency didn't make me feel like it's a static content and it's executing DB quires. While on my local machine, after the build, it's obvious that the pages are static. Probably I misconfigured something on AWS-side.
  • Secondly, this error only occurs on pages and API endpoints with dynamic routing.

The project that I'm working on is closed-source so I cannot share a sample code. But I can give you some info:

  • next version: 9.3.4
  • serverless-next.js version: ^1.11.1-alpha.0 (development dependency)

serverless.yml:

nextApp:
  component: "serverless-next.js"

next.config.js:

module.exports = {
  target: 'serverless',
}

and I deploy it by just running serverless.

@danielcondemarin
Copy link
Contributor

@mertyildiran Try version @1.11.1 (not the alpha) which includes a fix for catch all routes. That should fix the error you're seeing.
Also note that getStaticPaths and getStaticProps have still not been implemented. I have created an RFC for that : #355

@mertyildiran
Copy link
Contributor

@danielcondemarin yarn add serverless-next.js -D installed 1.11.1-alpha.0 by default. Downgrading to 1.11.1 solved the issue thank you so much! 😊

@afenton90
Copy link
Contributor

I'm encountering this issue with @sls-next/serverless-component@^1.17.0 still very intermittent, with no real pattern as to when the 503 appears, but I am getting the same error message as @ytwguru . Any thoughts on what could be causing this, or links to related issues @danielcondemarin ?

@danielcondemarin
Copy link
Contributor

@afenton90 Can you try using the latest alpha please https://github.com/serverless-nextjs/serverless-next.js/releases/tag/%40sls-next%2Fserverless-component%401.18.0-alpha.27 ? We're about to promote that alpha to stable soon.

@campbellgoe
Copy link

Just got same 503 error with component: "@sls-next/[email protected]" although this is the first time I've set up next-auth + magic email link so it might be something wrong on my side.

@grantmontgomery
Copy link

Also experiencing the same issue when trying to request an API route with Apollo. All my other api's work in production, but it's just this one that's coming back with the same error. My version of the sls-next/serverless component is also 1.18.0, but I'll try the latest alpha release.

@a-game
Copy link

a-game commented Jun 3, 2021

I just encountered the same problem with @sls-next/[email protected]

Error log:

{
    "errorType": "Error",
    "errorMessage": "Cannot find module '../chunks/775.js'\nRequire stack:\n- /var/task/pages/index.js\n- /var/task/default-handler-1d169422.js\n- /var/task/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
    "code": "MODULE_NOT_FOUND",
    "requireStack": [
        "/var/task/pages/index.js",
        "/var/task/default-handler-1d169422.js",
        "/var/task/index.js",
        "/var/runtime/UserFunction.js",
        "/var/runtime/index.js"
    ],
    "stack": [
        "Error: Cannot find module '../chunks/775.js'",
        "Require stack:",
        "- /var/task/pages/index.js",
        "- /var/task/default-handler-1d169422.js",
        "- /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 Object.__webpack_require__.f.require (/var/task/pages/index.js:1980:28)",
        "    at /var/task/pages/index.js:1904:40",
        "    at Array.reduce (<anonymous>)",
        "    at Function.__webpack_require__.e (/var/task/pages/index.js:1903:67)",
        "    at Function.__webpack_require__.x (/var/task/pages/index.js:1996:33)",
        "    at /var/task/pages/index.js:2018:57"
    ]
}

@dphang
Copy link
Collaborator

dphang commented Jun 3, 2021

@a-game That is due to newer Next.js versions changing their code-splitting, it should be fixed in the latest alpha version (note for future issues please first try to use the latest alpha as it might fix the bug you are encountering)

Also it is recommended to not comment on closed issues (unless its related and was not resolved) as it's hard for people to track except those already subscribed to that issue (And maintainers only get a single email)

@ViniciusFXavier
Copy link

Same error here

@rahuls-gfg
Copy link

I was facing this same issue, the error was happening because I have turned off the database in RDS. The backend service is unable to connect to the database.

Once the database is turned on, the app started working properly.

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