From 72458f5c419a3fa1abd756cf2b4ed3e490530b1b Mon Sep 17 00:00:00 2001 From: "Calum H." Date: Fri, 16 Jan 2026 19:56:46 +0000 Subject: [PATCH] feat: non-POJO check in rendered hook (#5137) * feat: non-POJO check in rendered hook Signed-off-by: Calum H. * fix: lint * move to plugin --------- Signed-off-by: Calum H. --- apps/frontend/src/plugins/debug-pojo.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 apps/frontend/src/plugins/debug-pojo.ts diff --git a/apps/frontend/src/plugins/debug-pojo.ts b/apps/frontend/src/plugins/debug-pojo.ts new file mode 100644 index 00000000..e9fe18c7 --- /dev/null +++ b/apps/frontend/src/plugins/debug-pojo.ts @@ -0,0 +1,24 @@ +import { defineNuxtPlugin } from '#imports' + +export default defineNuxtPlugin((nuxt) => { + if (import.meta.server) { + nuxt.hooks.hook('app:rendered', (ctx) => { + if (ctx.ssrContext?.payload?.data) { + const check = (obj: any, path = 'payload') => { + if (!obj || typeof obj !== 'object') return + if ( + obj.constructor && + obj.constructor.name !== 'Object' && + obj.constructor.name !== 'Array' + ) { + console.error(`Non-POJO at ${path}:`, obj.constructor.name) + } + for (const [k, v] of Object.entries(obj)) { + check(v, `${path}.${k}`) + } + } + check(ctx.ssrContext.payload.data) + } + }) + } +})