Files
nocodb/packages/nc-gui/plugins/error-handler.ts
Pranav C d4f76d348a fix: Miscellaneous bugs (#9149)
* feat: support pretty print in webhook json

* fix: on renaming table update default view name as well

* fix: show default view name alias as 'Default view'

* fix:  chunk loading error handling

* fix: global error boundary handling improvements

* fix: typo correction

* chore: sentry integration

* refactor: destroy the toast message after reload

* chore: add missing dependencies

Signed-off-by: Pranav C <pranavxc@gmail.com>

* chore: sentry error reporting

Signed-off-by: Pranav C <pranavxc@gmail.com>

* refactor: improved error toast message

Signed-off-by: Pranav C <pranavxc@gmail.com>

* refactor: timeout correction

Signed-off-by: Pranav C <pranavxc@gmail.com>

---------

Signed-off-by: Pranav C <pranavxc@gmail.com>
Co-authored-by: Raju Udava <86527202+dstala@users.noreply.github.com>
2024-08-07 12:39:57 +05:30

35 lines
1.1 KiB
TypeScript

// ref - https://github.com/nuxt/nuxt/issues/26565
export default defineNuxtPlugin((nuxtApp) => {
const MAX_RETRIES = 2
const QUERY_PARAM_NAME = 'reload_attempt'
const reload = () => {
const searchParams = new URLSearchParams(window.location.search)
const currentRetry = Number(searchParams.get(QUERY_PARAM_NAME)) || 0
if (currentRetry < MAX_RETRIES) {
console.log('[nuxt]: Reloading due to chunk error')
searchParams.set(QUERY_PARAM_NAME, (currentRetry + 1).toString())
// Changing the search also causes a refresh
window.location.search = searchParams.toString()
}
}
// Handle "Failed to fetch dynamically imported module ..." or similar issues
nuxtApp.hook('app:chunkError', () => {
reload()
})
nuxtApp.hook('app:error', (error) => {
const reload_error_list = [
'error loading dynamically imported module',
'Importing a module script failed',
'Failed to fetch dynamically imported module',
]
for (const message of reload_error_list) {
if (error.message.includes(message)) {
reload()
}
}
})
})