Closed superdav42 closed 1 year ago
All three gateway apps use the same code. I just tested gateway-edit and -admin and it work in both. So only gateway-translate is having this problem.
@superdav42 seems to work ok running locally (once you provide the .env
var values).
I changed the timeout to 10s and it still claims it is timing out. But the console shows this:
So now I am wondering if the problem is the "NonSSRWrapper" that I added early on because of other issues we were having (don't recall them at the moment).
So now I am wondering if the problem is the "NonSSRWrapper" that I added early on because of other issues we were having (don't recall them at the moment).
I wouldn't expect SSR to be related. It seems when I looked that nothing was setup at /api/feedback to respond to the request. Of course I wouldn't expect it to timeout either. So I don't know.
Current working hypothesis, notes, and next steps.
/api/feedback.js
is not created and the timeout happens when deployed. Running local seems to sidestep this problem... at least that's my theory.When I tried this, I first found that the sg mail package needed a polyfill for the fs package. So updated next.config.js to include this:
webpack: (config) => {
config.resolve.fallback = { fs: false };
return config;
},
Next I discovered that env variables that worked with the api folder code, would not work with a page. Finally found that I needed to add something else to next.config.js to allow the app to see the HELP DESK vars. The in total the file is now:
module.exports = {
env: {
NPM_PACKAGE_VERSION: process.env.npm_package_version,
HELP_DESK_EMAIL: process.env.HELP_DESK_EMAIL,
HELP_DESK_TOKEN: process.env.HELP_DESK_TOKEN,
BUILD_NUMBER: require('child_process')
.execSync('git rev-parse --short HEAD')
.toString().trim(),
},
webpack: (config) => {
config.resolve.fallback = { fs: false };
return config;
},
}
@superdav42 FYI
The root cause of the problem is in v4 of @netlify/plugin-nextjs api function operate very differently from v3. I think all the other apps are using v3 of this plugin and v11 or v10 of nextjs. Since this is a newer repos we set it up with the latest. v4 of the plugin seems to create one function called ___netlify-handler which handles all api requests. V3 creates a function for each endpoint in our case it's called next_api_feedback. Because of this bug https://github.com/netlify/next-runtime/issues/1174 when using v4 the function timesout on AWS lambda after 10s while it is starting up before it can serve any requests. PR #122 Fixes the problem by downgrading @netlify/plugin-nextjs to v 3.9.2 and and next js to v11.1.4. The app seems to work fine on the older versions so I think we'll keep it this way for now.
To get the latest version working according to the issue we will probably need to update all the l rcl's to change the imports as described.
One can see the problem using the netlify-cli and running netlify serve
. The file at `.netlify/functions/___netlify-handler.zip should be much smaller and not contain all the mui icons and mui code. As it is the file is 27MB but the next_api_feedback.zip with v3 is 600KB. Before the v4 code will work the generated zip will probably need to be less than 1MB.
It always timesout.