Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make ss rnode safe #6
base: master
Are you sure you want to change the base?
Make ss rnode safe #6
Changes from 4 commits
e56953c
fbee62c
aa35ecd
24c1466
cf3ca57
81ffbe3
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could have an early return here directly, shouldn't we throw if not supported ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmm just starting to test this now, although I suspect throwing might lead to SSR failing in practice. I think from a practical point of view if index DB doesn't exist the user should expect just to return the default value. anyway I'll test that assumption now that rejecting will case SSR builds to fail in my codebase at least anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep just tried this change and it crashes my SSR code, and build code in a gatsby project.
in SSR we if hasIDB is false then it should gracefully degrade to the returning the default value which will make the code SSR safe.
seeing I technically haven't made your requested change I won't hit the resolve button so that you can review it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well the idea would be to catch it in your usercode and handle it the way you want. Is that a problem ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, before this PR my code base would crash even just from importing it (unless you assigned it with a conditional require statement).
So... We can leave error checking to user but needs to at least not fail on import. I'll double check that's working in my code base later tonight for you. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok just to confirm if we reject here because this promise runs straight away on import it will cause any SSR code to error just by importing it. (unless you instead assign it with a conditional require statement)
@kigiri which Option Do you want me to run with to Resolve?
I'll keep playing to see if another way :)