Asymmetry in Memento API's JSON encoding/decoding #209479
Labels
api
bug
Issue identified by VS Code Team member as probable bug
confirmed
Issue has been confirmed by VS Code Team member
debt
Code quality issues
insiders-released
Patch has been released in VS Code Insiders
workbench-state
UI state across restarts
Milestone
I expected Memento's
get
to recover the JSON-stringifyable object but it doesn't always.Repro: hyangah/vscode-extension-samples@194f02e
In this repro, I stored a
Date
object usingupdate
, and later attempted to retrieve the value usingget<Date>
.The first round (immediately storing the value) works as expected, except that the value doesn't match the usual ISO 8601 format (JSON.stringify returns)
Restart the extension. Now this time, the error will be thrown, because
context.globalState.get<Date>(KEY)
is not aDate
object. It's string. I am guessingget
failed to parse the persisted JSON string (ISO 8601 format), and silently returned a string object.I think this code used to work last year, but recently, we started to notice problems caused by this asymmetry.
Did Memento API get changed recently?
The text was updated successfully, but these errors were encountered: