Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dumps *gigantic* object into console on error #14529

Closed
2 tasks done
ChristopherJTrent opened this issue Apr 18, 2024 · 5 comments · Fixed by #14568
Closed
2 tasks done

Dumps *gigantic* object into console on error #14529

ChristopherJTrent opened this issue Apr 18, 2024 · 5 comments · Fixed by #14568
Milestone

Comments

@ChristopherJTrent
Copy link

ChristopherJTrent commented Apr 18, 2024

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

8.3.1

Node.js version

21.6.2

MongoDB server version

Irrelevant

Typescript version (if applicable)

No response

Description

Every time I have a problem with mongoose, it decides to dump a gigantic (larger than my terminal scrollback, which is set to 1 billion lines) object into the console.
This makes it completely impossible to diagnose anything.
I have mongoose.set('debug', false),
I don't have any other loggers enabled.

Steps to Reproduce

Happens in random places in this repo: https://github.com/acheung-94/pet-portal/tree/buildNewPetForm
notably when you send a put request to /api/pets/:id

Expected Behavior

I expect there to be some way to get mongoose to not dump the entire mongoose object to console

@ChristopherJTrent ChristopherJTrent closed this as not planned Won't fix, can't repro, duplicate, stale Apr 19, 2024
@vkarpov15
Copy link
Collaborator

Do you have a sample of what the output looks like?

@vkarpov15 vkarpov15 reopened this May 1, 2024
@vkarpov15 vkarpov15 added this to the 8.3.4 milestone May 1, 2024
@Automattic Automattic deleted a comment from ChristopherJTrent May 3, 2024
@vkarpov15
Copy link
Collaborator

@ChristopherJTrent I deleted your comment because the message you pasted includes your database connection string with username and password. I'd recommend you update your username and password just in case.

@vkarpov15
Copy link
Collaborator

Also worth noting, your output includes 12 server restarts, most of which have the same error. So the error output isn't quite that large as that. But we'll look into it and see what we can do on our end, or what changes we can recommend to your morgan config to make the logs more readable.

@ChristopherJTrent
Copy link
Author

ChristopherJTrent commented May 3, 2024

@ChristopherJTrent I deleted your comment because the message you pasted includes your database connection string with username and password. I'd recommend you update your username and password just in case.

Thank you, I didn't realize. My DBA is issuing me new creds. (but not without a stern talking to <_< >_>)

@vkarpov15
Copy link
Collaborator

I wouldn't say it's entirely your fault, it is surprising that an error originating from casting an update would contain your database connection string. This has to do with how Node.js serializes errors to the console, doesn't affect how errors end up in JSON or anywhere else.

vkarpov15 added a commit that referenced this issue May 5, 2024
@vkarpov15 vkarpov15 modified the milestones: 8.3.4, 8.4 May 6, 2024
vkarpov15 added a commit that referenced this issue May 6, 2024
fix(error): remove model property from CastError to avoid printing all model properties to console
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants