You've already forked AstralRinth
forked from didirus/AstralRinth
feat: more o11y for i18n pojo (#5148)
This commit is contained in:
17
apps/frontend/src/plugins/intl-payload-safety.ts
Normal file
17
apps/frontend/src/plugins/intl-payload-safety.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
export default definePayloadPlugin(() => {
|
||||
definePayloadReducer('IntlMessageFormat', (value) => {
|
||||
if (value?.constructor?.name === 'IntlMessageFormat' || value?._ast !== undefined) {
|
||||
if (import.meta.dev) {
|
||||
console.warn('[i18n] IntlMessageFormat instance leaked into payload - returning null')
|
||||
console.warn('[i18n] This indicates a bug that should be fixed upstream')
|
||||
console.warn('[i18n] Leaked value:', value)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
|
||||
definePayloadReviver('IntlMessageFormat', () => null)
|
||||
})
|
||||
Reference in New Issue
Block a user