Skip to content

Conversation

@wattanx
Copy link
Collaborator

@wattanx wattanx commented Dec 5, 2023

πŸ”— Linked issue

#1001

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

The error returned by useLazyAsyncData remained null even if there was an error. (if ssr: false)
Fixed to behave the same as nuxt 3.
https://stackblitz.com/edit/github-drhhpj-bd1bnm

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@wattanx wattanx force-pushed the fix/use-lazy-async-data-error branch from d82b749 to 6d76c0e Compare December 5, 2023 14:05
@wattanx wattanx marked this pull request as ready for review December 5, 2023 14:10
@wattanx wattanx force-pushed the fix/use-lazy-async-data-error branch from 6d76c0e to eb19428 Compare December 6, 2023 14:11
@wattanx wattanx requested a review from danielroe December 11, 2023 01:22
data: _ref(options.getCachedData!(key) ?? options.default!()),
pending: ref(!hasCachedData()),
error: toRef(nuxt.payload._errors, key),
error: ref(nuxt.payload._errors[key]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this will mean that the error is 'disconnected' from the payload and won't be included in it.

Is there a reason that toRef isn't reactive here? If so, we might need to add an additional assignment to the payload when the error is thrown below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, it seems this wasn't essential. It might be because _errors is not reactive.

state._errors = state._errors || {}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that might be right πŸ‘

@wattanx wattanx force-pushed the fix/use-lazy-async-data-error branch from eb19428 to 22b5f6c Compare December 13, 2023 14:30
Copy link
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘Œ

@danielroe danielroe merged commit d03fbb4 into main Dec 13, 2023
@danielroe danielroe deleted the fix/use-lazy-async-data-error branch December 13, 2023 17:44
@github-actions github-actions bot mentioned this pull request Dec 13, 2023
@github-actions github-actions bot mentioned this pull request Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants