Skip to content

fix: round-trip special values from nested stringifyAsync promises - #214

Open
devtechedge wants to merge 1 commit into
sveltejs:mainfrom
devtechedge:fix/stringify-async-nested-sentinels
Open

devtechedge wants to merge 1 commit into
sveltejs:mainfrom
devtechedge:fix/stringify-async-nested-sentinels

Conversation

@devtechedge

@devtechedge devtechedge commented Sep 29, 2026 •

Copy link
Copy Markdown

A promise of undefined, NaN, -0, Infinity, or -Infinity already round-trips when it is the root value passed to stringifyAsync. Nested inside an object or array, the pre-assigned slot held the sentinel number, so parse revived -1, -3, -6, -4, or -5.

The parent back-reference now points at the sentinel, and the unused slot is dropped, so the output matches stringify of the plain value.

Fixes #211

A nested promise of undefined, NaN, -0, Infinity, or -Infinity was stored as a slot holding the sentinel number, so parse revived that number. Inline the sentinel into the parent back-reference and drop the unused slot so the output matches stringify.

Fixes sveltejs#211
@changeset-bot

changeset-bot Bot commented Sep 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c57d432

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
devalue Patch

Not sure what this means? Click here to learn what changesets are.

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

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.

stringifyAsync: a promise resolving to undefined, NaN, -0 or Infinity inside an object parses back as -1, -3, -6 or -4

1 participant