Skip to content

DRAFT: display potential way to make undefined correct value for PersistedState#408

Draft
kraktus wants to merge 1 commit intosvecosystem:mainfrom
kraktus:undefined_pstate
Draft

DRAFT: display potential way to make undefined correct value for PersistedState#408
kraktus wants to merge 1 commit intosvecosystem:mainfrom
kraktus:undefined_pstate

Conversation

@kraktus
Copy link

@kraktus kraktus commented Feb 26, 2026

see #391 and #411

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.

This PR is a demonstration on how to get undefined to be a valid correct value. 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.

@changeset-bot
Copy link

changeset-bot bot commented Feb 26, 2026

⚠️ No Changeset found

Latest commit: 9fb8136

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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.
@kraktus kraktus changed the title wip DRAFT: display potential way to make undefined correct value for PersistedState Feb 27, 2026
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.

1 participant