Next.js + PM2 + IIS deployment - error when switching between pages quickly (Internal Server Error) - iis

https://github.com/vercel/next.js/issues/33292
logs in PM2 show this error
| 2022-12-22T10:43:16: Error: invariant: static responses cannot be piped. This is a bug in Next.js
Any ideas on where I can debug?

Related

Nodejs app on Phusion Passenger(R) crashing randomly

I'm hosting my Nodejs app with plesk obsidian and Phusion Passenger(R).
Sometimes the application just shows this error and I have to restard the whole server to fix it.
Error:
The Phusion Passenger(R) application server tried to start the web application through a Passenger-internal helper tool called the "wrapper". But Passenger was unable to execute that helper tool because it encountered an internal error.
The stdout/stderr output of the subprocess so far is:
[ D 2022-09-24 14:20:50.3578 575180/T1 age/Spa/SpawnEnvSetupperMain.cpp:747 ]: shellName = 'false' detected as supporting '-l': false
Images:
Error Output
Problem Location
If you need more information to help me with this problem feel free to ask.

Vercel deployment, enviormental variables

Hey guys im trying to deploy my website and I keep getting stuck on these issues vercel build then vercel deploy -- prebuilt I get the error message of Error: ENOENT: no such file or directory, stat '/vercel/path0/.vercel/output/functions/_next/data/f3doRdmrRJC9QWLs2rG4w/index.json.func'
But when I run vercel deploy depending on my environmental variables for NEXT_PUBLIC_BASE_URL if I put http://portfolio-build-lem0bum28-bchang0999.vercel.app as my value the result i get is Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error FetchError: invalid json response body at https://vercel.com/login?next=%2Fdeployments%2Fportfolio-build-lem0bum28-bchang0999.vercel.app%3Fhost%3Dportfolio-build-lem0bum28-bchang0999.vercel.app%26redirect%3D1%26section%3D reason: Unexpected token < in JSON at position 0
if i put the NEXT_PUBLIC_BASE_URL with a value of http://localhost:3000 the error code I get is FetchError: request to http://localhost:3000/api/getPageInfo failed, reason: connect ECONNREFUSED 127.0.0.1:3000
any help to resolve this so I can deploy and move on from this project would be nice
http://portfolio-build-lem0bum28-bchang0999.vercel.app errorlocalhost:3000 error

Express App on Azure cannot load static file, status 500

I am deploying an Node.js Express App on Azure and the app failed to load static css/js file. The static file works fine under my localhost:3000. But when running on Azure, it throw out Internal Server Error 500.
The error in my chrome looks like:
GET https:///resources/css/style.css net::ERR_ABORTED 500 (Internal Server Error). The directory tree for this css file is /public/resources/css
I assume that my static file path is correct, otherwise I would see a 404 error instead of 500
app.use(express.static(path.join(__dirname, 'public')));
Per my experience, I think the incorrect deployment cause the error code 500 of Internal Server Error in Node.js on Azure. So to fix it, please first check the content of your web.config file in the path site/wwwroot. And there is a standard sample web.config from Kudu wiki page Using a custom web.config for Node apps which you can refer to.
If your Node app deployed successed, you will see a 404 Not Found error code for a non-exist static file instead of 500 as you said.
However, there is a difference for the variable __dirname between local and Azure. On local, the value of __dirname variable is always the full path name where you start up a node process, such as print __dirname will return D:\home if run node in CMD at D:\home. But on Azure, you will see the __dirname value in any path which be . if you try to run the command node -e "const path = require('path'); console.log(__dirname);" in the Kudu console, as the figure below.
Therefore, the path.join(__dirname, 'public') value is always public which not be related to the current path of node started up by IIS. So to fix it, please use an absolute path like D:\home\site\wwwroot instead of __dirname variable in path.join method or just directly use D:\home\site\wwwroot\public in express.static method.
Solved!
I checked the DetailedErrors log files from Azure Diagnostic Tool. And it was showing the 500 error was due to the following:
HTTP Error 500.0 - Internal Server Error
D:\Python34\python.exe - The FastCGI process exited unexpectedly
In fact, in my Azure App Service application setting, I turn on the python 3.4 version and which somehow azure trying to handle my static request using python. I simply turn off the python version in my application setting and now I can successfully load my static file.

NodeJS app (Keystone JS) runs fine when started manually, restarts over and over when started with pm2

I am using Ubuntu 16.04 x 64 and I'm running into an issue -
When I run my Keystone JS app manually by typing in "node keystone", the app runs fine and I can view it in my browser like normal.
However, when I start the app using pm2, the app fails immediately and restarts consecutively.
I think it is because keystonejs has a known "error" that is not a real error, but just a warning when it starts.
From the "keystone-out-0.log" file -
Error ...node_modules/bson/build/Release/bson.node: invalid ELF header
However, in the "keystone-error-0.log" file, it gives me a different error that does not occur when I run it manually -
Error: ENOENT: no such file or directory, open '.env'
Any one faced anything similar?
Thanks

Nodejitsu while while starting node.js app

I am very new to node.js, I just followed the steps to create a simple node.js application. Here it is on github
I ran the command jitsu deploy from the terminal to deploy it on nodejitsu, however I got this error right here, please any help on what could be wrong with code files?
Here is the code on git hub
Here is the error that is appearing:
prompt: Is this ok?: (yes) yes
info: Creating snapshot 0.0.0-5
info Uploading: [=============================] 100%
info: Updating app test
info: Activating snapshot 0.0.0-5 for test
info: Starting app test
error: Error running command deploy
error: Nodejitsu Error (500): Internal Server Error
error: There was an error while attempting to deploy the app
error:
error: Error spawning drone
error: Script took too long to listen on a socket
error:
error: This type of error is usually a user error.
error: Error output from Haibu:
error:
error: Error: Error spawning drone
error: at Object.onTimeout [as _onTimeout] (/root/haibu-orchestra/node_mod
ules/haibu/lib/haibu/core/spawner.js:396:15)
error: at Timer.list.ontimeout (timers.js:101:19)
help: For help with this error contact Nodejitsu Support:
help: webchat: <http://webchat.nodejitsu.com/>
help: irc: <irc://chat.freenode.net/#nodejitsu>
help: email: <support#nodejitsu.com>
You're server.js is exporting a function, but that doesn't get run. Just the body of your start function as top-level code directly inside the server.js module so that it executes when nodejitsu starts your application.
Nodejitsu is very picky about how quick your deployments listen on the system. There is a certain time frame between the start of deployment and end of deployment before your deployment is considered a failure. When it doesn't listen on a port for so long, it ends up giving you this error.
Rather than using your current start function, why don't you try creating your HTTP socket in index.js and then passing it into your start function as well, since you're already passing routes and handle to it?
For example, in index.js:
var http = require('http'),
server = http.createServer().listen(8080);
start(server, router.route, handle);
Then, rather than using http.createServer(onRequest).listen(8080) in your server.js file, you can use something like:
var start = function (server, route, handle) {
function onRequest(request, response) {
/* Your request stuff here */
}
server.on('request', onRequest);
};
This would most likely solve the whole problem.

Resources