Skip to content

Commit

Permalink
Resolve a bug that caused initialization to fail in some cases (#620)
Browse files Browse the repository at this point in the history
* Try to throw new Error

* Fix the bug

* Test logging

* Fix test?

* Test throws error now?
  • Loading branch information
sebazai authored Jun 29, 2021
1 parent ff0d708 commit 8c52f13
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [2.0.3] - 2021-06-28

#### Fixed
- Bug when migrating Session state that caused extension to fail initialization in some cases.

## [2.0.2] - 2021-04-13

#### Fixed
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "test-my-code",
"displayName": "TestMyCode",
"description": "TestMyCode extension for Visual Studio Code",
"version": "2.0.2",
"version": "2.0.3",
"license": "MIT",
"publisher": "moocfi",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/migrate/migrateSessionState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const SESSION_STATE_KEY_V1 = "session-state-v1";
const UNSTABLE_EXTENSION_VERSION_KEY = "extensionVersion";

export interface SessionStateV1 {
extensionVersion: string | undefined;
extensionVersion?: string | undefined;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/migrate/validateData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function validateData<T>(
}

if (!validator(data)) {
throw Error(`Data type missmatch: ${JSON.stringify(data)}`);
throw new Error(`Data type missmatch: ${JSON.stringify(data)}`);
}

return data;
Expand Down
2 changes: 1 addition & 1 deletion src/test/migrate/migrateSessionState.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ suite("Session state migration", function () {

suite("with stable data", function () {
test("fails with garbage version 1 data", async function () {
await memento.update(SESSION_STATE_KEY_V1, { wonderwoman: "Diana Prince" });
await memento.update(SESSION_STATE_KEY_V1, { extensionVersion: 1 });
expect(() => migrateSessionState(memento)).to.throw(/missmatch/);
});
});
Expand Down

0 comments on commit 8c52f13

Please sign in to comment.