From 194f02e3418ec293956be62e732a43b33d483fbb Mon Sep 17 00:00:00 2001 From: "Hana (Hyang-Ah) Kim" Date: Wed, 3 Apr 2024 15:27:38 -0400 Subject: [PATCH] Bug repro - asymmetry in Memento API when using Date object --- helloworld-sample/package.json | 2 +- helloworld-sample/src/extension.ts | 32 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/helloworld-sample/package.json b/helloworld-sample/package.json index 1fe5d5562..ece890160 100644 --- a/helloworld-sample/package.json +++ b/helloworld-sample/package.json @@ -11,7 +11,7 @@ "categories": [ "Other" ], - "activationEvents": [], + "activationEvents": ["onStartupFinished"], "main": "./out/extension.js", "contributes": { "commands": [ diff --git a/helloworld-sample/src/extension.ts b/helloworld-sample/src/extension.ts index 7fa9da092..6b590cae5 100644 --- a/helloworld-sample/src/extension.ts +++ b/helloworld-sample/src/extension.ts @@ -19,5 +19,37 @@ export function activate(context: vscode.ExtensionContext) { vscode.window.showInformationMessage('Hello World!'); }); + const now = new Date(); + console.log(JSON.stringify(now)); + const KEY = 'TEST_TIMESTAMP_KEY'; + let value = context.globalState.get(KEY); + if (value === undefined) { + context.globalState.update(KEY, new Date()); + value = context.globalState.get(KEY); + } + console.log(`TEST_TIMESTAMP_KEY = ${value} type=${typeof value}`); + if (value === undefined || !(value instanceof Date)) { + throw Error(`unexpected date - ${value}`); + } context.subscriptions.push(disposable); } + +/* +# First Round + +Congratulations, your extension "helloworld-sample" is now active! +extensionHostProcess.js:144 +"2024-04-03T19:24:17.476Z" +extensionHostProcess.js:144 +TEST_TIMESTAMP_KEY = Wed Apr 03 2024 15:24:17 GMT-0400 (Eastern Daylight Time) type=object + +-- +# Second Round + +Congratulations, your extension "helloworld-sample" is now active! +extensionHostProcess.js:144 +"2024-04-03T19:25:06.045Z" +extensionHostProcess.js:144 +TEST_TIMESTAMP_KEY = 2024-04-03T19:24:17.478Z type=string +(and crash) +*/ \ No newline at end of file