PM2 and nextjs stop responding request after a few uptime - reactjs

My current setup is nginx -> reverse proxy -> nextjs. I"m using pm2 with cluster mode for nextjs. The problem is after nextjs is up for like 10 mins, it's stop responding without a trace of error but this issue is resolved when I restart nextjs app with pm2 restart all. It looks like my nextjs app only live for 10 mins and after that I have to restart. So I have to run a cron job to do this.
pm2 log output
2020-01-14T09:40:02: PM2 log: App [npm:0] starting in -cluster mode-
2020-01-14T09:40:02: PM2 log: App [npm:0] online
2020-01-14T09:40:02: PM2 log: App [npm:1] starting in -cluster mode-
2020-01-14T09:40:02: PM2 log: App [npm:1] online
2020-01-14T09:40:02: PM2 log: App [npm:2] starting in -cluster mode-
2020-01-14T09:40:03: PM2 log: App [npm:2] online
2020-01-14T09:40:03: PM2 log: App [npm:3] starting in -cluster mode-
2020-01-14T09:40:03: PM2 log: App [npm:3] online
2020-01-14T09:40:03: PM2 log: App [npm:4] starting in -cluster mode-
2020-01-14T09:40:03: PM2 log: App [npm:4] online
2020-01-14T09:40:03: PM2 log: App [npm:5] starting in -cluster mode-
2020-01-14T09:40:03: PM2 log: App [npm:5] online
2020-01-14T09:40:03: PM2 log: App [npm:6] starting in -cluster mode-
2020-01-14T09:40:03: PM2 log: App [npm:6] online
2020-01-14T09:40:03: PM2 log: App [npm:7] starting in -cluster mode-
2020-01-14T09:40:03: PM2 log: App [npm:7] online
> Server started at http://localhost:3000 with development ? false
events.js:187
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1306:14)
at listenInCluster (net.js:1354:12)
at Server.listen (net.js:1442:7)
at /Users/username/Data/Projects/reactjs/ssr/server.js:90:8
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1333:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'EADDRINUSE',
errno: -48,
syscall: 'listen',
address: '::',
port: 3000
}
events.js:187
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1306:14)
at listenInCluster (net.js:1354:12)
at Server.listen (net.js:1442:7)
at /Users/username/Data/Projects/reactjs/ssr/server.js:90:8
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1333:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'EADDRINUSE',
errno: -48,
syscall: 'listen',
address: '::',
port: 3000
}
events.js:187
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1306:14)
at listenInCluster (net.js:1354:12)
at Server.listen (net.js:1442:7)
at /Users/username/Data/Projects/reactjs/ssr/server.js:90:8
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1333:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'EADDRINUSE',
errno: -48,
syscall: 'listen',
address: '::',
port: 3000
}
events.js:187
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1306:14)
at listenInCluster (net.js:1354:12)
at Server.listen (net.js:1442:7)
at /Users/username/Data/Projects/reactjs/ssr/server.js:90:8
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1333:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'EADDRINUSE',
errno: -48,
syscall: 'listen',
address: '::',
port: 3000
}
events.js:187
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1306:14)
at listenInCluster (net.js:1354:12)
at Server.listen (net.js:1442:7)
at /Users/username/Data/Projects/reactjs/ssr/server.js:90:8
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1333:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'EADDRINUSE',
errno: -48,
syscall: 'listen',
address: '::',
port: 3000
}
events.js:187
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1306:14)
at listenInCluster (net.js:1354:12)
at Server.listen (net.js:1442:7)
at /Users/username/Data/Projects/reactjs/ssr/server.js:90:8
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1333:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'EADDRINUSE',
errno: -48,
syscall: 'listen',
address: '::',
port: 3000
}

Though you did not mention using npm, I fixed a similar issue by removing usage of npm from the ecosystem.config.json file.
Before (not working):
{
"apps": [
{
...
"script": "/usr/bin/npm",
"args" : "start",
...
}
]
}
After (working):
{
"apps": [
{
...
"script": "./node_modules/.bin/next",
"args" : "start -p 3000",
...
}
]
}
I did not take time to dig into the issue with npm.
I found the solution here: express server port configuration issue with pm2 cluster mode

Related

'at emitErrorNT (node:internal/streams/destroy:151:8)' trying to build nextjs website

I was trying to build my nextjs website and got this error
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -4048,
code: 'EPERM',
syscall: 'open', path: 'E:\\ECell Project\\ecell-uptodat\\ecell-main\\.next\\trace'
}
I am unable to figure out what is causing this error.

The file path is correct but not when using fs.readFileSync?

So i have a system that only saves to files when the bot is shutdown to prevent file corruption.
When the bot starts it reads these files and put the data into a library.
The issue im having is that when trying to read the file the path is invalid.
// How my files are stored:
Databases: {
Default: {
Errors.json
}
Exchangeable: {
Errors.js
}
}
bot startup code:
if (command === "startup") { // line 14 > 18
await require(`../Default/Errors.json`); // this is a valid path / gives no error
let rawdata = await fs.readFileSync('../Default/Errors.json'); // invalid path / gives the error
Data = await JSON.parse(rawdata);
}
Error:
node:events:368
throw er; // Unhandled 'error' event
^
Error: ENOENT: no such file or directory, open '../Default/Errors.json'
at Object.openSync (node:fs:585:3)
at Object.readFileSync (node:fs:453:35)
at Object.execute (C:\Users\NAME\Desktop\Botters\C.U.A.L - Bot V2\Databases\Exchangeable\Errors.js:16:36)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Client.<anonymous> (C:\Users\NAME\Desktop\Botters\C.U.A.L - Bot V2\main.js:69:9)
Emitted 'error' event on Client instance
at:
at emitUnhandledRejectionOrErr (node:events:251:10)
at processTicksAndRejections (node:internal/process/task_queues:85:21) {
errno: -4058,
syscall: 'open',
code: 'ENOENT',
path: '../Default/Errors.json'
}

reactide is not setting up in windows 10 causing problems while executing yarn run build

I have recently cloned Reactide from github after executing following commands.
git checkout 3.0-release
yarn install
yarn run build
I got following error:
$ yarn run build
yarn run v1.21.1
$ electron-builder
• electron-builder version=20.44.4
• loaded configuration file=package.json ("build" field)
• writing effective config file=release-builds\builder-effective-config.yaml
• no native production dependencies
• packaging platform=win32 arch=x64 electron=3.1.13 appOutDir=release-bu
ilds\win-unpacked
panic: runtime error: index out of range
goroutine 1 [running]:
github.com/develar/app-builder/pkg/icons.doConvertIcon(0xc000061440, 0x4, 0x4, 0
xc000130bc0, 0x2, 0x2, 0xc0000640a0, 0x3, 0xc00006a050, 0x45, ...)
/Volumes/data/Documents/app-builder/pkg/icons/icon-converter.go:223 +0xf
20
github.com/develar/app-builder/pkg/icons.ConvertIcon(0xc000061340, 0x0, 0x0, 0x0
)
/Volumes/data/Documents/app-builder/pkg/icons/icon-converter.go:56 +0xdd
github.com/develar/app-builder/pkg/icons.ConfigureCommand.func1(0xc00019fb90, 0x
409e4a, 0xb440c0)
/Volumes/data/Documents/app-builder/pkg/icons/icon-converter.go:33 +0x75
github.com/alecthomas/kingpin.(*actionMixin).applyActions(0xc0000c8c18, 0xc00019
fb90, 0x0, 0x0)
/Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin#v2.2.6+incompatib
le/actions.go:28 +0x74
github.com/alecthomas/kingpin.(*Application).applyActions(0xc0000ca690, 0xc00019
fb90, 0x0, 0x0)
/Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin#v2.2.6+incompatib
le/app.go:557 +0xe3
github.com/alecthomas/kingpin.(*Application).execute(0xc0000ca690, 0xc00019fb90,
0xc0001b4b30, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1)
/Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin#v2.2.6+incompatib
le/app.go:390 +0x96
github.com/alecthomas/kingpin.(*Application).Parse(0xc0000ca690, 0xc0000a0010, 0
x9, 0xf, 0xc0000ca690, 0xc0001dbf88, 0x405846, 0xc000056058)
/Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin#v2.2.6+incompatib
le/app.go:222 +0x20a
main.main()
/Volumes/data/Documents/app-builder/main.go:78 +0x34a
Error: C:\Users\Admin\Desktop\React Course\reactide\node_modules\app-builder-bin
\win\x64\app-builder.exe exited with code 2
at ChildProcess. (C:\Users\Admin\Desktop\React Course\reactide\no
de_modules\builder-util\src\util.ts:244:14)
at Object.onceWrapper (events.js:300:26)
at ChildProcess.emit (events.js:210:5)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
From previous event:
at WinPackager.resolveIcon (C:\Users\Admin\Desktop\React Course\reactide\nod
e_modules\app-builder-lib\src\platformPackager.ts:594:101)
at C:\Users\Admin\Desktop\React Course\reactide\node_modules\app-builder-lib
\src\platformPackager.ts:573:31
at Generator.next ()
From previous event:
at WinPackager.getOrConvertIcon (C:\Users\Admin\Desktop\React Course\reactid
e\node_modules\app-builder-lib\src\platformPackager.ts:572:54)
at Lazy. (C:\Users\Admin\Desktop\React Course\reactide\node_modul
es\app-builder-lib\src\winPackager.ts:79:43)
at Lazy.get value [as value] (C:\Users\Admin\Desktop\React Course\reactide\n
ode_modules\lazy-val\src\main.ts:18:25)
at WinPackager.getIconPath (C:\Users\Admin\Desktop\React Course\reactide\nod
e_modules\app-builder-lib\src\winPackager.ts:190:27)
at C:\Users\Admin\Desktop\React Course\reactide\node_modules\app-builder-lib
\src\winPackager.ts:287:33
at Generator.next ()
From previous event:
at WinPackager.signAndEditResources (C:\Users\Admin\Desktop\React Course\rea
ctide\node_modules\app-builder-lib\src\winPackager.ts:260:158)
at C:\Users\Admin\Desktop\React Course\reactide\node_modules\app-builder-lib
\src\winPackager.ts:362:21
at go$readdir$cb (C:\Users\Admin\Desktop\React Course\reactide\node_modules\
graceful-fs\graceful-fs.js:187:14)
at FSReqCallback.oncomplete (fs.js:146:23)
From previous event:
at C:\Users\Admin\Desktop\React Course\reactide\node_modules\app-builder-lib
\src\winPackager.ts:360:27
at Generator.next ()
From previous event:
at WinPackager.signApp (C:\Users\Admin\Desktop\React Course\reactide\node_mo
dules\app-builder-lib\src\winPackager.ts:354:73)
at C:\Users\Admin\Desktop\React Course\reactide\node_modules\app-builder-lib
\src\platformPackager.ts:250:16
at Generator.next ()
at processImmediate (internal/timers.js:439:21)
From previous event:
at WinPackager.doPack (C:\Users\Admin\Desktop\React Course\reactide\node_mod
ules\app-builder-lib\src\platformPackager.ts:167:165)
at C:\Users\Admin\Desktop\React Course\reactide\node_modules\app-builder-lib
\src\platformPackager.ts:113:16
at Generator.next ()
From previous event:
at WinPackager.pack (C:\Users\Admin\Desktop\React Course\reactide\node_modul
es\app-builder-lib\src\platformPackager.ts:111:95)
at C:\Users\Admin\Desktop\React Course\reactide\node_modules\app-builder-lib
\src\packager.ts:430:24
at Generator.next ()
at C:\Users\Admin\Desktop\React Course\reactide\node_modules\fs-extra-p\node
_modules\fs-extra\lib\mkdirs\mkdirs.js:56:16
at callback (C:\Users\Admin\Desktop\React Course\reactide\node_modules\grace
ful-fs\polyfills.js:295:20)
at FSReqCallback.oncomplete (fs.js:159:5)
From previous event:
at Packager.doBuild (C:\Users\Admin\Desktop\React Course\reactide\node_modul
es\app-builder-lib\src\packager.ts:396:24)
at C:\Users\Admin\Desktop\React Course\reactide\node_modules\app-builder-lib
\src\packager.ts:366:57
at Generator.next ()
at C:\Users\Admin\Desktop\React Course\reactide\node_modules\graceful-fs\gra
ceful-fs.js:136:16
at C:\Users\Admin\Desktop\React Course\reactide\node_modules\graceful-fs\gra
ceful-fs.js:57:14
at FSReqCallback.oncomplete (fs.js:146:23)
From previous event:
at Packager._build (C:\Users\Admin\Desktop\React Course\reactide\node_module
s\app-builder-lib\src\packager.ts:335:133)
at C:\Users\Admin\Desktop\React Course\reactide\node_modules\app-builder-lib
\src\packager.ts:331:23
at Generator.next ()
at processImmediate (internal/timers.js:439:21)
From previous event:
at Packager.build (C:\Users\Admin\Desktop\React Course\reactide\node_modules
\app-builder-lib\src\packager.ts:288:14)
at build (C:\Users\Admin\Desktop\React Course\reactide\node_modules\app-buil
der-lib\src\index.ts:59:28)
at build (C:\Users\Admin\Desktop\React Course\reactide\node_modules\electron
-builder\src\builder.ts:228:10)
at C:\Users\Admin\Desktop\React Course\reactide\node_modules\electron-builde
r\src\cli\cli.ts:49:19
error Command failed with exit code 1.
I have also tried this command
git checkout 3.0-release
yarn install
yarn run webpack-production
But got following error:
$ yarn run webpack-production
yarn run v1.21.1
$ webpack --mode production
C:\Users\Admin\Desktop\React Course\reactide\node_modules\webpack-cli\bin\cli.js
:281
throw err;
^
Error: Cannot find module 'monaco-editor\esm\vs\editor\contrib\gotoSymbol\goToCo
mmands'
Require stack:
- C:\Users\Admin\Desktop\React Course\reactide\node_modules\monaco-editor-webpac
k-plugin\out\index.js
- C:\Users\Admin\Desktop\React Course\reactide\webpack.config.js
- C:\Users\Admin\Desktop\React Course\reactide\node_modules\webpack-cli\bin\util
s\convert-argv.js
- C:\Users\Admin\Desktop\React Course\reactide\node_modules\webpack-cli\bin\cli.
js
- C:\Users\Admin\Desktop\React Course\reactide\node_modules\webpack\bin\webpack.
js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
at Function.resolve (C:\Users\Admin\Desktop\React Course\reactide\node_modul
es\v8-compile-cache\v8-compile-cache.js:166:23)
at resolveMonacoPath (C:\Users\Admin\Desktop\React Course\reactide\node_modu
les\monaco-editor-webpack-plugin\out\index.js:26:20)
at C:\Users\Admin\Desktop\React Course\reactide\node_modules\monaco-editor-w
ebpack-plugin\out\index.js:161:63
at Array.map ()
at createLoaderRules (C:\Users\Admin\Desktop\React Course\reactide\node_modu
les\monaco-editor-webpack-plugin\out\index.js:161:43)
at MonacoEditorWebpackPlugin.apply (C:\Users\Admin\Desktop\React Course\reac
tide\node_modules\monaco-editor-webpack-plugin\out\index.js:80:23)
at webpack (C:\Users\Admin\Desktop\React Course\reactide\node_modules\webpac
k\lib\webpack.js:51:13)
at processOptions (C:\Users\Admin\Desktop\React Course\reactide\node_modules
\webpack-cli\bin\cli.js:272:16)
at C:\Users\Admin\Desktop\React Course\reactide\node_modules\webpack-cli\bin
\cli.js:364:3
at Object.parse (C:\Users\Admin\Desktop\React Course\reactide\node_modules\w
ebpack-cli\node_modules\yargs\yargs.js:567:18)
at C:\Users\Admin\Desktop\React Course\reactide\node_modules\webpack-cli\bin
\cli.js:49:8
at Object. (C:\Users\Admin\Desktop\React Course\reactide\node_mod
ules\webpack-cli\bin\cli.js:366:3)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (C:\Users\Admin\Desktop\React Course\reactide\node_mod
ules\webpack\bin\webpack.js:156:2)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
at internal/main/run_main_module.js:17:11 {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Admin\\Desktop\\React Course\\reactide\\node_modules\\monaco-edi
tor-webpack-plugin\\out\\index.js',
'C:\\Users\\Admin\\Desktop\\React Course\\reactide\\webpack.config.js',
'C:\\Users\\Admin\\Desktop\\React Course\\reactide\\node_modules\\webpack-cl
i\\bin\\utils\\convert-argv.js',
'C:\\Users\\Admin\\Desktop\\React Course\\reactide\\node_modules\\webpack-cl
i\\bin\\cli.js',
'C:\\Users\\Admin\\Desktop\\React Course\\reactide\\node_modules\\webpack\\b
in\\webpack.js'
]
}
error Command failed with exit code 1.
Please help me to debug this.
Thanks in advance...

Azure issue with Allure

I got this error while generate and run allure report
throw er; // Unhandled 'error' event
^
at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: 'EACCES',
code: 'EACCES',
syscall: 'spawn /Users/runner/runners/2.160.1/work/_tasks/AllureGenerate_5c975f9d-1c3a-469f-b7c2-8907bf3eacfb/1.0.0/node_modules/allure-commandline/dist/bin/allure',
path: '/Users/runner/runners/2.160.1/work/_tasks/AllureGenerate_5c975f9d-1c3a-469f-b7c2-8907bf3eacfb/1.0.0/node_modules/allure-commandline/dist/bin/allure',
spawnargs: [
'generate',
'--output',
'/Users/runner/runners/2.160.1/work/1/s/allure-report/45',
'/Users/runner/runners/2.160.1/work/1/s/allure-results'
]
} ```

I'm facing with this error while creating the first project in angularjs?

events.js:167
throw er; // Unhandled 'error' event
^
> Error: spawn C:\WINDOWS\system32\cmd.exe; ENOENT
> at Process.ChildProcess._handle.onexit (internal/child_process.js:232:19)
> at onErrorNT (internal/child_process.js:407:16)
> at process._tickCallback (internal/process/next_tick.js:63:19)
> Emitted 'error' event at:
> at Process.ChildProcess._handle.onexit (internal/child_process.js:238:12)
> at onErrorNT (internal/child_process.js:407:16)
> at process._tickCallback (internal/process/next_tick.js:63:19)

Resources