Open adamhl8 opened 4 years ago
Turns out things like unhandled promise rejections won't be timestamped, but as long as you actually catch errors the timestamp works properly.
I closed this too quickly. Should have done more testing, sorry.
It looks like only caught errors are timestamped, any other error isn't. Is that intended?
Can you send me a sample code so I try it out
For example:
var promise = new Promise(function(resolve, reject) {
if (false) {
}
else {
reject(Error("It broke"));
}
});
promise.then().catch(console.error);
In my error log I'll get an entry with the correct timestamp: 2019-11-25 06:25:13: Error: It broke
If I remove the .catch
, an error is logged with no timestamp: You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection: Error: It broke
This doesn't just apply to unhandled promise rejections though. If you have something like let foo = bar
where bar
doesn't exist it will throw an error without a timestamp. In other words, the only time I've seen errors have a timestamp is when I catch rejected promises.
I'm having the same issue with "exec_mode: cluster" on ecosystem.config.js. If I disable cluster mode it works.
PM2 version 4.1.2
Yep, after setting exec_mode
to "fork"
the logging/timestamps work as expected. Thanks.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I'm having the same issue, when I use "exec_mode: cluster", my error_log files won't include timestamps, but when I change to fork mode, timestamps appear.
My PM2 version is v4.5.6
I haveing the same issue, when i setting exec_mode as cluster. my PM2 version is v5.1.2
I confirm this issue. Sometimes there is timestamp in error log, but most of time there is no timestamp for repeated errors during multiple days.
ecosystem.config.cjs
:
module.exports = {
apps: [{
name: 'games-admin',
exec_mode: 'cluster',
instances: '1',
cwd: '/srv/games-admin/api',
script: 'dist/main.js',
args: '--name games-admin --time',
interpreter_args: '',
merge_logs: true,
log_date_format: 'YYYY-MM-DD HH:mm:ss Z'
}]
}
~/.pm2/logs/games-admin-error.log
:
You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
PrismaClientValidationError:
Invalid `this.db.tgChatMessage.create()` invocation in ...
...
You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
PrismaClientValidationError:
Invalid `this.db.tgChatMessage.create()` invocation in ...
...
You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
PrismaClientValidationError:
Invalid `this.db.tgChatMessage.create()` invocation in ...
...
2024-09-27 20:15:33 +03:00: error: [polling_error] {"code":"EFATAL","message":"EFATAL: Error: read ETIMEDOUT"}
I have my
ecosystem.config.js
file set up like this:I have timestamps in my
out_file
log, but none in myerror_file
log.I'm using verison
4.1.2
.