acronie
acronie11mo ago

Bad request in prod but works fine in dev

in prod I am getting BAD REQUEST
17 Replies
acronie
acronie11mo ago
No description
acronie
acronie11mo ago
Nothing logs on the server If anyone has any idea let me know please I am stuck deploying my application useQuery works fine for now. and other mutations too
Nick
Nick11mo ago
o.from sounds a lot like you’re sending over some bundled JS instead of JSON
acronie
acronie11mo ago
bundled js? do I need to stringify the object I am passing? I dont think so right?
scheduleInterview.mutate({
employeeId,
startTime: dayjs(dateTime).toDate(),
});
scheduleInterview.mutate({
employeeId,
startTime: dayjs(dateTime).toDate(),
});
this is what it is
NeoBean
NeoBean11mo ago
could be caused by the Date() object
acronie
acronie11mo ago
coming from dayjs? How tho? I feel its that too but not really sure z dateTime is coming from datetime input @neobean
NeoBean
NeoBean11mo ago
well toDate() method returns an entire javascript Date() class
acronie
acronie11mo ago
Hmmm But how does it work in dev mode? I would surely see something
NeoBean
NeoBean11mo ago
idk honestly, but im curious
acronie
acronie11mo ago
export const ScheduleInterviewSchema = z.object({
employeeId: z.string().nonempty(),
startTime: z.date(),
});
export const ScheduleInterviewSchema = z.object({
employeeId: z.string().nonempty(),
startTime: z.date(),
});
using z.date which expects the whole date ig
NeoBean
NeoBean11mo ago
and you're using superjson too right?
acronie
acronie11mo ago
I assume yes Id need to check yes I am transformer: superjson,
NeoBean
NeoBean11mo ago
if its not for the date, it could be for anything, you need debug chunk by chunk ¯\_(ツ)_/¯
acronie
acronie11mo ago
this is the payload of the network request
No description
acronie
acronie11mo ago
{
"0": {
"json": {
"employeeId": "clm8uz2zd0000mc2hucjj3czl",
"startTime": "2023-09-07T15:22:00.000Z"
},
"meta": {
"values": {
"startTime": [
"Date"
]
}
}
}
}
{
"0": {
"json": {
"employeeId": "clm8uz2zd0000mc2hucjj3czl",
"startTime": "2023-09-07T15:22:00.000Z"
},
"meta": {
"values": {
"startTime": [
"Date"
]
}
}
}
}
whcih i think is valid date too idk whats causing the error then
NeoBean
NeoBean11mo ago
are you using errorFormatters / try catch anywhere that just throws BAD_REQUEST/INTERNAL_SERVER_ERROR but doesnt log or respond with a proper message/error data? also you using mongodb? if employeeId is supposed to be an objectId, its invalid have you tried running the production mode locally? is everything same for both dev/prod? like payload, database configuration/indexes etc
acronie
acronie11mo ago
no Works locally