Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
feat: use built-in .toJSON()
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Oct 27, 2022
1 parent e5f7506 commit 79f21bb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 29 deletions.
2 changes: 1 addition & 1 deletion packages/nuxi/package.json
Expand Up @@ -35,7 +35,7 @@
"execa": "^6.1.0",
"flat": "^5.0.2",
"giget": "^0.1.7",
"h3": "^0.8.5",
"h3": "^0.8.6",
"jiti": "^1.16.0",
"listhen": "^0.3.4",
"mlly": "^0.5.16",
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/package.json
Expand Up @@ -52,7 +52,7 @@
"escape-string-regexp": "^5.0.0",
"fs-extra": "^10.1.0",
"globby": "^13.1.2",
"h3": "^0.8.5",
"h3": "^0.8.6",
"hash-sum": "^2.0.0",
"hookable": "^5.4.1",
"knitwork": "^0.1.2",
Expand Down
18 changes: 2 additions & 16 deletions packages/nuxt/src/app/composables/asyncData.ts
Expand Up @@ -169,22 +169,8 @@ export function useAsyncData<
asyncData.pending.value = false
nuxt.payload.data[key] = asyncData.data.value
if (asyncData.error.value) {
// Use `createError` to normalize the error
const _err = createError(asyncData.error.value)
const err = { ..._err }
// Strip as many keys out as possible to reduce payload size
err.message = _err.message
delete err.stack
// @ts-expect-error
delete err.__nuxt_error
// @ts-expect-error
delete err.fatal
// @ts-expect-error
delete err.unhandled
if (err.data && !Object.keys(err.data).length) {
delete err.data
}
nuxt.payload._errors[key] = err
// We use `createError` and its .toJSON() property to normalize the error
nuxt.payload._errors[key] = createError(asyncData.error.value)
}
delete nuxt._asyncDataPromises[key]
})
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/package.json
Expand Up @@ -33,7 +33,7 @@
"externality": "^0.2.2",
"fs-extra": "^10.1.0",
"get-port-please": "^2.6.1",
"h3": "^0.8.5",
"h3": "^0.8.6",
"knitwork": "^0.1.2",
"magic-string": "^0.26.7",
"mlly": "^0.5.16",
Expand Down
20 changes: 10 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 79f21bb

Please sign in to comment.