Skip to content

refactor(fs): Use structuredClone for Resource statInfo deep copy#1401

Merged
RandomByte merged 1 commit into
mainfrom
fix/fs-resource-structured-clone
Jun 1, 2026
Merged

refactor(fs): Use structuredClone for Resource statInfo deep copy#1401
RandomByte merged 1 commit into
mainfrom
fix/fs-resource-structured-clone

Conversation

@RandomByte
Copy link
Copy Markdown
Member

@RandomByte RandomByte commented Jun 1, 2026

Up-port of SAP/ui5-fs#697


The clone package recreates internal-slot-backed values like Date and
Temporal.Instant as prototype-only copies, stripping the slot. On Node 26
fs.Stats exposes Temporal.Instant getters whose toJSON performs a strict
internal-slot check and throws, breaking any consumer that JSON-stringifies
a cloned stat (e.g. @ui5/builder's theme worker IPC).

Replace clone with a small helper that preserves the prototype, copies
function-valued own properties by reference, and runs each data value through
structuredClone — which correctly handles Date, Temporal, Map, Set, typed
arrays, etc. sourceMetadata uses structuredClone directly. The unmaintained
clone dependency is removed from @ui5/fs.

This is an up-port of SAP/ui5-fs#697 hence the
commit message is not using the "fix" prefix.

The `clone` package recreates internal-slot-backed values like Date and
Temporal.Instant as prototype-only copies, stripping the slot. On Node 26
fs.Stats exposes Temporal.Instant getters whose toJSON performs a strict
internal-slot check and throws, breaking any consumer that JSON-stringifies
a cloned stat (e.g. @ui5/builder's theme worker IPC).

Replace `clone` with a small helper that preserves the prototype, copies
function-valued own properties by reference, and runs each data value through
structuredClone — which correctly handles Date, Temporal, Map, Set, typed
arrays, etc. sourceMetadata uses structuredClone directly. The unmaintained
`clone` dependency is removed from @ui5/fs.

This is an up-port of SAP/ui5-fs#697 hence the
commit message is not using the "fix" prefix.
@RandomByte RandomByte requested a review from a team June 1, 2026 13:51
@RandomByte RandomByte merged commit 7aff80b into main Jun 1, 2026
59 checks passed
@RandomByte RandomByte deleted the fix/fs-resource-structured-clone branch June 1, 2026 14:14
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.

2 participants