DRAFT: display potential way to make undefined correct value for PersistedState#408
Draft
kraktus wants to merge 1 commit intosvecosystem:mainfrom
Draft
DRAFT: display potential way to make undefined correct value for PersistedState#408kraktus wants to merge 1 commit intosvecosystem:mainfrom
undefined correct value for PersistedState#408kraktus wants to merge 1 commit intosvecosystem:mainfrom
Conversation
|
kraktus
added a commit
to kraktus/runed
that referenced
this pull request
Feb 27, 2026
…red type `undefined` already used internally by `PersistedState` as a special case to indicate that the value is not present in storage, and in case of deserialisation failure. This make using `undefined` in user-code a footgun, because for example `persistentState.current = undefined` is not working as expected, being a NOOP instead of emptying the state. Alternatively another approach would be allow undefined state. A draft PR is available here: svecosystem#408. I did not get to the end of it, because the issue is that undefined has no valid JSON value, so it would require additional (de)serialisation logic, especially for custom ones.
kraktus
added a commit
to kraktus/runed
that referenced
this pull request
Feb 27, 2026
…alid value in the stored type `undefined` already used internally by `PersistedState` as a special case to indicate that the value is not present in storage, and in case of deserialisation failure. This make using `undefined` in user-code a footgun, because for example `persistentState.current = undefined` is not working as expected, being a NOOP instead of emptying the state. While this is technically a breaking-change, I consider it a patch because the user-code impacted is buggy anyway. Alternatively another approach would be allow undefined state. A draft PR is available here: svecosystem#408. I did not get to the end of it, because the issue is that undefined has no valid JSON value, so it would require additional (de)serialisation logic, especially for custom ones.
kraktus
added a commit
to kraktus/runed
that referenced
this pull request
Feb 27, 2026
…alid value in the stored type `undefined` already used internally by `PersistedState` as a special case to indicate that the value is not present in storage, and in case of deserialisation failure. This make using `undefined` in user-code a footgun, because for example `persistentState.current = undefined` is not working as expected, being a NOOP instead of emptying the state. While this is technically a breaking-change, I consider it a patch because the user-code impacted is buggy anyway. Alternatively another approach would be allow undefined state. A draft PR is available here: svecosystem#408. I did not get to the end of it, because the issue is that undefined has no valid JSON value, so it would require additional (de)serialisation logic, especially for custom ones.
kraktus
added a commit
to kraktus/runed
that referenced
this pull request
Feb 27, 2026
…valid value in the stored type `undefined` already used internally by `PersistedState` as a special case to indicate that the value is not present in storage, and in case of deserialisation failure. This make using `undefined` in user-code a footgun, because for example `persistentState.current = undefined` is not working as expected, being a NOOP instead of emptying the state. While this is technically a breaking-change, I consider it a patch because the user-code impacted is buggy anyway. Alternatively another approach would be allow undefined state. A draft PR is available here: svecosystem#408. I did not get to the end of it, because the issue is that undefined has no valid JSON value, so it would require additional (de)serialisation logic, especially for custom ones.
kraktus
added a commit
to kraktus/runed
that referenced
this pull request
Feb 27, 2026
…valid value in the stored type `undefined` is already used internally by `PersistedState` as a special case to indicate that the value is not present in storage, and in case of deserialisation failure. This make using `undefined` in user-code a footgun, because for example `persistentState.current = undefined` is not working as expected, being a NOOP instead of emptying the state. While this is technically a breaking-change, I consider it a patch because the user-code impacted is buggy anyway. Alternatively another approach would be allow undefined state. A draft PR is available here: svecosystem#408. I did not get to the end of it, because the issue is that undefined has no valid JSON value, so it would require additional (de)serialisation logic, especially for custom ones.
This was referenced Feb 27, 2026
undefined correct value for PersistedState
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
see #391 and #411
undefinedis already used internally byPersistedStateas a special case to indicate that the value is not present in storage, and in case of deserialisation failure.This make using
undefinedin user-code a footgun, because for examplepersistentState.current = undefinedis not working as expected, being a NOOP instead of emptying the state.This PR is a demonstration on how to get
undefinedto be a valid correct value. I did not get to the end of it, because the issue is thatundefinedhas no valid JSON value, so it would require additional (de)serialisation logic, especially for custom ones.