# Migrating from 1.0.0-alpha.267 The stash extension speaks RESP3 to Redis, and hands your operations the protocol's own types. ## Why `context.stash.` is a proxy onto an ioredis client, so its replies are whatever the wire protocol carried. That was RESP2, which has three types — string, integer, array — and encodes everything else in them. A sorted set score arrived as the string `"1.5"`. A map arrived as a flat array, keys and values alternating, with nothing in the reply saying it was a map. RESP3 has the types. ioredis 6 speaks it, and offers to translate back to the old shapes — a `replyMapping: "legacy"` default whose whole purpose is to make the upgrade invisible. Taking it would have meant the extension knowing a reply was a map and handing you an array anyway, indefinitely. The reply now says what it is. ## What changed Four things. Every one of them was measured against Redis 7 rather than read off a compatibility table, and everything not listed here is byte-identical to before. ### Scores come back as numbers ```js await context.stash.zscore('scores', member) // was '1.5', now 1.5 ``` `ZSCORE`, `ZINCRBY`, `ZMSCORE` and `ZADD … INCR`. Doubles nested inside another reply convert too — inside a `multi()`/`pipeline()` result, and inside `MEMORY STATS`. `INCRBYFLOAT` and `HINCRBYFLOAT` are **not** affected. Redis returns those as bulk strings under both protocols, so they are still strings. ### Member/score pairs are pairs now, not a flat list ```js await context.stash.zrange('z', 0, -1, 'WITHSCORES') // was ['a', '1.5', 'b', '2'] // now [['a', 1.5], ['b', 2]] ``` The same for `HRANDFIELD … WITHVALUES`. This is the one most likely to be sitting in your code: a `for (let i = 0; i < reply.length; i += 2)` over a flat array now walks pairs. ### Maps come back as objects ```js await context.stash.config('GET', 'maxmemory') // was ['maxmemory', '0'] // now { maxmemory: '0' } ``` `CONFIG GET`, `XINFO STREAM`, `MEMORY STATS` — and nested maps within them, such as `MEMORY STATS`' `db.0`. `HGETALL` is **not** affected. ioredis has always transformed it into an object, and it still does — `hgetallBuffer()` likewise, with string keys and Buffer values exactly as before. ### Lua scripts that opt in A script sees RESP2 unless it calls `redis.setresp(3)` itself, so `EVAL` returns what it always did. A script that does opt in can now return types it could not before: ```js await context.stash.eval('redis.setresp(3); return true', 0) // was 1, now true ``` Booleans reach you no other way — no core Redis command returns one. `SISMEMBER`, `EXISTS` and `TTL` still return integers. ### Not affected Worth stating so you do not go looking. Sets are still arrays (`SMEMBERS`, `SRANDMEMBER`). Big numbers and verbatim strings are still strings. `GET`, `GETBUFFER` and `XRANGE` are unchanged, and so is every null — a `SPOP` miss, a `BLPOP` timeout, an `LPOS` miss. `store` and `fetch` are unchanged. They ride on bulk strings, which RESP3 leaves alone, so msgpackr gets the same bytes. The distributed lock is unchanged, and so is anything else built on `EVAL`. One cosmetic thing, if you happen to parse it: `CLIENT INFO` now reports `resp=3`. ## What to do Read your operations for the four cases above. Sorted sets and `CONFIG GET` are where to look first; if you use neither, there is nothing here for you. A score read as a string and parsed still works — `Number(1.5)` is `1.5`. What breaks is code that compares against a string, checks `typeof`, or concatenates: ```js const score = await context.stash.zscore('scores', member) if (score === '1.5') … // never true now if (Number(score) === 1.5) … // correct before and after ``` What breaks silently is precision. A score past what a double holds exactly used to arrive as the digits Redis sent, and now arrives rounded. If you were relying on that, you were relying on the string, and you need `stringNumbers` — which the extension does not expose. Say so on the issue tracker rather than working around it. The flat-array reads are mechanical: ```js const [, maxmemory] = await context.stash.config('GET', 'maxmemory') // before const { maxmemory } = await context.stash.config('GET', 'maxmemory') // now for (let i = 0; i < reply.length; i += 2) // before use(reply[i], reply[i + 1]) for (const [member, score] of reply) // now use(member, score) ``` There is no per-application opt-out. The extension does not expose `protocol` or `replyMapping`, and a knob would only defer the reading once rather than remove it. ## Also in this release `redlock-temp-fix` is gone. It was a republished copy of `redlock@5.0.0-beta.2`, taken years ago because the original was broken and never fixed upstream — that project's last release was in 2022. `stash.lock` now runs on [`@sesamecare-oss/redlock`](https://github.com/sesamecare/redlock), a maintained continuation of the same implementation with the same algorithm and the same semantics. Nothing to do. `lock(id, routine)` behaves as it did. One thing to know if you run a license scan: that package ships `LICENSE.md` with the MIT text but declares `"license": "UNLICENSED"` in its `package.json`, so scanners flag it. The licence is MIT; the metadata is wrong upstream.