When using @flareapp/flare-client
with nuxt I get the following error server side.
Nuxt automatically handles errors by sending the user to the /error.vue
component. Which I have a script setup like this:
<script setup lang="ts">
import { flare } from '@flareapp/flare-client';
// report error
flare.report(props.error);
</script>
<template>
...
</template>
However, when nuxt catches an error and redirects the user to this page, I get the following error from flare:
[nitro] [dev] [unhandledRejection] ReferenceError: document is not defined 7:58:31 AM
at f (/Users/ianjamieson/tixel/content-nuxt/node_modules/@flareapp/flare-client/dist/index.js:1:7042)
at /Users/ianjamieson/tixel/content-nuxt/node_modules/@flareapp/flare-client/dist/index.js:1:15761
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Now, if I only report the error client side:
if(process.client) {
// report error
flare.report(props.error);
}
Then the error goes away.
I have also tested to see if errors come through to flare despite the warning showing, and they don't.
I have tested by putting:
flare.report({
message: `from store, client: ${process.client}`
});
Inside a store which is executed server side, and I do not see any error in flare, just the document undefined error.