Skip to content

Commit 8c52f13

Browse files
authored
Resolve a bug that caused initialization to fail in some cases (#620)
* Try to throw new Error * Fix the bug * Test logging * Fix test? * Test throws error now?
1 parent ff0d708 commit 8c52f13

File tree

6 files changed

+10
-5
lines changed

6 files changed

+10
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## [2.0.3] - 2021-06-28
4+
5+
#### Fixed
6+
- Bug when migrating Session state that caused extension to fail initialization in some cases.
7+
38
## [2.0.2] - 2021-04-13
49

510
#### Fixed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "test-my-code",
33
"displayName": "TestMyCode",
44
"description": "TestMyCode extension for Visual Studio Code",
5-
"version": "2.0.2",
5+
"version": "2.0.3",
66
"license": "MIT",
77
"publisher": "moocfi",
88
"repository": {

src/migrate/migrateSessionState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const SESSION_STATE_KEY_V1 = "session-state-v1";
88
const UNSTABLE_EXTENSION_VERSION_KEY = "extensionVersion";
99

1010
export interface SessionStateV1 {
11-
extensionVersion: string | undefined;
11+
extensionVersion?: string | undefined;
1212
}
1313

1414
/**

src/migrate/validateData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default function validateData<T>(
77
}
88

99
if (!validator(data)) {
10-
throw Error(`Data type missmatch: ${JSON.stringify(data)}`);
10+
throw new Error(`Data type missmatch: ${JSON.stringify(data)}`);
1111
}
1212

1313
return data;

src/test/migrate/migrateSessionState.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ suite("Session state migration", function () {
5252

5353
suite("with stable data", function () {
5454
test("fails with garbage version 1 data", async function () {
55-
await memento.update(SESSION_STATE_KEY_V1, { wonderwoman: "Diana Prince" });
55+
await memento.update(SESSION_STATE_KEY_V1, { extensionVersion: 1 });
5656
expect(() => migrateSessionState(memento)).to.throw(/missmatch/);
5757
});
5858
});

0 commit comments

Comments
 (0)