Skip to content
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

fix: handle Buffer serialization #277

Merged
merged 1 commit into from
Dec 9, 2022
Merged

fix: handle Buffer serialization #277

merged 1 commit into from
Dec 9, 2022

Conversation

olizilla
Copy link
Contributor

@olizilla olizilla commented Dec 9, 2022

Buffer has a toJSON implementation which is called before our replacer function when serialising. It's JSON form is an object like { type: 'Buffer, data: number[] }.

This means it doesn't get identfied as $bytes, and does not get deserialised in the reviver. I think we'd rather have Uint8Array everywhere so this PR fixes it so that it gets revived as that.

License: MIT
Signed-off-by: Oli Evans oli@protocol.ai

Buffer has a toJSON implementation which is called before our replacer function when serialising. It's JSON form is an object like { type: 'Buffer, data: number[] }`.

This gets mangled in storage and does not get deserilaised in the reviver. I think we'd rather have UintA8Arrays everywhere so this PR fixes it so that it gets revived as that.

License: MIT
Signed-off-by: Oli Evans <oli@protocol.ai>
@olizilla olizilla requested a review from alanshaw December 9, 2022 15:53
@olizilla olizilla temporarily deployed to dev December 9, 2022 15:54 — with GitHub Actions Inactive
@olizilla olizilla merged commit 6dc77ca into main Dec 9, 2022
@olizilla olizilla deleted the buffer-serialize branch December 9, 2022 23:32
alanshaw pushed a commit that referenced this pull request Dec 13, 2022
🤖 I have created a release *beep* *boop*
---


##
[9.1.0](access-v9.0.1...access-v9.1.0)
(2022-12-13)


### Features

* sync encode/decode delegations
([#276](#276))
([ab981fb](ab981fb))


### Bug Fixes

* destructured save
([#272](#272))
([a4f20a9](a4f20a9))
* handle Buffer serialization
([#277](#277))
([6dc77ca](6dc77ca))
* make d1 spaces.metadata nullable and change to kysely
([#284](#284))
([c8a9ce5](c8a9ce5)),
closes [#280](#280)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
gobengo pushed a commit that referenced this pull request Apr 11, 2023
Buffer has a toJSON implementation which is called before our replacer
function when serialising. It's JSON form is an object like `{ type:
'Buffer, data: number[] }`.

This means it doesn't get identfied as $bytes, and does not get
deserialised in the reviver. I think we'd rather have `Uint8Array`
everywhere so this PR fixes it so that it gets revived as that.

License: MIT
Signed-off-by: Oli Evans <oli@protocol.ai>
gobengo pushed a commit that referenced this pull request Apr 11, 2023
🤖 I have created a release *beep* *boop*
---


##
[9.1.0](access-v9.0.1...access-v9.1.0)
(2022-12-13)


### Features

* sync encode/decode delegations
([#276](#276))
([9d48372](9d48372))


### Bug Fixes

* destructured save
([#272](#272))
([b6aaf9b](b6aaf9b))
* handle Buffer serialization
([#277](#277))
([8e8f745](8e8f745))
* make d1 spaces.metadata nullable and change to kysely
([#284](#284))
([7f09479](7f09479)),
closes [#280](#280)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

3 participants