cloudflare / cloudflare/workers-rs
[BUG] KV deserialization broke between `worker` `0.0.13` and `0.0.17` (`worker-kv` `0.5` and `0.6`)
- Dominant language
- Rust
- Stars
- 3.7k
- Forks
- 429
- Avg merge
- 20h 28m
- Merged PRs (30d)
- 7
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### What version of `workers-rs` are you using?
0.0.17
### What version of `wrangler` are you using?
3.2.0
### Describe the bug
The project at https://github.com/u32i64/signalupdates-bot/tree/dcc4abc965913174bc0480b56e67ff035f62426f compiles and deploys successfully, however trying to run it causes the following error when reading state from KV that looks like this:
```json
{
"android": {
"last_posted_tag_previous_release": {
"name": "..."
},
"last_posted_tag": {
"name": "..."
},
"last_post": {
"id": 123456,
"number": 123
},
"posted_archiving_message": true,
"localization_changes_completeness": "Incomplete",
"localization_changes": {
"kk": [
"Main"
],
},
"pending_state": null
},
"desktop": { /* ... */ },
"ios": { /* ... */ }
}
```
```
ERROR signalupdates_bot: error=could not get value for key state
Caused by:
js error: JsValue(Error: invalid type: string "kk", expected a borrowed string
Error: invalid type: string "kk", expected a borrowed string
at ct (shim.js:369:11)
at wasm://wasm/00e8ef02:wasm-function[812]:0x103639
at wasm://wasm/00e8ef02:wasm-function[1076]:0x1357cf
at wasm://wasm/00e8ef02:wasm-function[149]:0x542ce
at wasm://wasm/00e8ef02:wasm-function[126]:0xdb86
at wasm://wasm/00e8ef02:wasm-function[294]:0xb637c
at wasm://wasm/00e8ef02:wasm-function[462]:0xe0076
at wasm://wasm/00e8ef02:wasm-function[1782]:0x145b24
at tt (shim.js:141:5)
at b (shim.js:127:14))
```
I suspect the issue is with the deserialization of the [`Language`](https://github.com/u32i64/signalupdates-bot/blob/dcc4abc965913174bc0480b56e67ff035f62426f/src/localization/language.rs#L7-L13) struct.
I tried setting `try_from = "String"` and providing a corresponding impl, that did not fix the issue.
The "solution" was downgrading `worker-kv` and then downgrading `worker` until the project builds (https://github.com/u32i64/signalupdates-bot/commit/d46e6a4124fa95d56005efe9cb3df05347c832a5). After that the project deploys and deserializes the state successfully.
Considering the downgrade affected `serde-wasm-bindgen`, could be that the issue is in https://github.com/cloudflare/serde-wasm-bindgen.
### Steps To Reproduce
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.