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

fix: unhelpful "cannot overwrite model once compiled" errors swallowing actual error #11057

Merged
merged 1 commit into from
Feb 8, 2025

Conversation

AlessioGr
Copy link
Member

@AlessioGr AlessioGr commented Feb 8, 2025

If an error is thrown during the payload init process, it gets ignored and an unhelpful, meaningless

⨯ OverwriteModelError: Cannot overwrite ___ model once compiled.

error is thrown instead. The actual error that caused this will never be logged. This PR fixes this and ensures the actual error is logged.

Why did this happen?

If an error is thrown during the init process, it is caught and handled by the src/utilities/routeError.ts - this helper properly logs the error using pino.
The problem is that pino did not exist, as payload did not finish initializing - it errored during it. So, it tries to initialize payload again before logging the error... which will fail again. If payload failed initializing the first time, it will fail the second time. => No error is logged.

This PR ensures the error is logged using console.error() if the originating error was thrown during the payload init process, instead of attempting to initialize it again and again

@AlessioGr AlessioGr enabled auto-merge (squash) February 8, 2025 07:16
@AlessioGr AlessioGr merged commit 6a99677 into main Feb 8, 2025
74 checks passed
@AlessioGr AlessioGr deleted the fix/payload-init-error-swallowed branch February 8, 2025 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant