R
Railway14mo ago
arcoz

dayjs tz function dont work on railway

Hello, is the nodejs Date object handle other that in windows ? I have this error in production Argument gte for where.date.gte is not a valid Date object. but in local i don't have a error
Solution:
I'd write the dockerfile for you, but I'm currently limited to mobile right now
Jump to solution
27 Replies
Percy
Percy14mo ago
Project ID: 152ff848-e90d-48e6-9bfd-f487495da195
arcoz
arcoz14mo ago
how i get the date :
import {DayJS} from '$core/utils/function/dayjs/dayjs';

export const getToday = (): Date => {
return DayJS().tz().set('hour', 0).set('minute', 0).set('seconds', 0).utc().toDate();
};
import {DayJS} from '$core/utils/function/dayjs/dayjs';

export const getToday = (): Date => {
return DayJS().tz().set('hour', 0).set('minute', 0).set('seconds', 0).utc().toDate();
};
Definition of DayJS :
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';

dayjs.extend(utc);
dayjs.extend(timezone);

dayjs.tz.setDefault('Europe/Paris');

export const DayJS = dayjs;
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';

dayjs.extend(utc);
dayjs.extend(timezone);

dayjs.tz.setDefault('Europe/Paris');

export const DayJS = dayjs;
Full error :
PrismaClientValidationError: Argument gte for where.date.gte is not a valid Date object.
at Ui.validate (/app/node_modules/@prisma/client/runtime/library.js:148:73)
at gn.createMessage (/app/node_modules/@prisma/client/runtime/library.js:164:1298)
at /app/node_modules/@prisma/client/runtime/library.js:177:11600
at Object.runInChildSpan (/app/node_modules/@prisma/client/runtime/library.js:174:1394)
at t._executeRequest (/app/node_modules/@prisma/client/runtime/library.js:177:11577)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at getBumpsByUserInGuildToday (/app/src/handlers/database/bump/bump.func.ts:71:24)
at MessageCreate.checkBump (/app/src/events/message_create/message_create.class.ts:106:28) {
clientVersion: '4.16.2'
PrismaClientValidationError: Argument gte for where.date.gte is not a valid Date object.
at Ui.validate (/app/node_modules/@prisma/client/runtime/library.js:148:73)
at gn.createMessage (/app/node_modules/@prisma/client/runtime/library.js:164:1298)
at /app/node_modules/@prisma/client/runtime/library.js:177:11600
at Object.runInChildSpan (/app/node_modules/@prisma/client/runtime/library.js:174:1394)
at t._executeRequest (/app/node_modules/@prisma/client/runtime/library.js:177:11577)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at getBumpsByUserInGuildToday (/app/src/handlers/database/bump/bump.func.ts:71:24)
at MessageCreate.checkBump (/app/src/events/message_create/message_create.class.ts:106:28) {
clientVersion: '4.16.2'
before i don't use .tz() but i got not the good date, it filter with utc timezone, and for my project i neeted French timezone hours
Brody
Brody14mo ago
oh wow I didn't know this was still an issue, and the solution usually ends up being use a Dockerfile
arcoz
arcoz14mo ago
i have found a thing here : https://stackoverflow.com/questions/75129234/day-js-timezone-plugin-method-produce-an-invalid-date a issue with nodejs fixed after 18.13 Is possible to start in a specific minor version or not ?
Stack Overflow
day.js timezone plugin method produce an invalid Date
I used a long time, dayjs in an angular project, to convert timestamps in a rest response from UTC to localtime. After my last update, it does not work anymore. It is not the first problem with day...
Brody
Brody14mo ago
nope, but there's a possibility that specifying node 18 could use a node 18 version greater than 18.13 in your package.json set engines.node to 18
arcoz
arcoz14mo ago
i have add node version in env variable
Brody
Brody14mo ago
and what version is actually being installed
arcoz
arcoz14mo ago
arcoz
arcoz14mo ago
i don't have info about minor version
Mozzy
Mozzy14mo ago
v18.12.1 from one of my bots
Brody
Brody14mo ago
temporarily change your start command to node --version or whatever prints the version lol ah thanks mozzy so I assume if this is fixed in 18.13 it would also be fixed in 19x?
arcoz
arcoz14mo ago
yes i think but nixpacks only accept 14, 16 and 18 no ?
Brody
Brody14mo ago
damn you right well back to the original solution, dockerfile
Gaetan 🐈
Gaetan 🐈14mo ago
@arcoz no, sorry i don't know
arcoz
arcoz14mo ago
i can use another version of node with that ?
Want results from more Discord servers?
Add your server