Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error launching session on desktop in v2.12.2 #4469

Merged
merged 1 commit into from
Jun 26, 2024
Merged

Conversation

cmdcolin
Copy link
Collaborator

Fixes error "Error: Error invoking remote method 'createInitialAutosaveFile': ReferenceError: Cannot access 'path' before initialization" in v2.12.2

I changed the typescript config in v2.12.2 and so the generated js code for the electron main script was

ipcMain.handle('createInitialAutosaveFile', async (_event, snap) => {
    const rows = await readRecentSessions();
    const idx = rows.findIndex(r => r.path === path);
    const path = getAutosavePath(`${+Date.now()}`);

In v2.11.2 it used a complex down-transpilation that resulted in var declarations that were hoisted

ipcMain.handle('createInitialAutosaveFile', function (_event, snap) { return __awaiter(void 0, void 0, void 0, function () {
    var rows, idx, path, entry;
    var _a;
    return __generator(this, function (_b) {
        switch (_b.label) {
            case 0: return [4 /*yield*/, readRecentSessions()];
            case 1:
                rows = _b.sent();
                idx = rows.findIndex(function (r) { return r.path === path; });
                path = getAutosavePath("".concat(+Date.now()));

this PR fixes the variable declaration order, and also renames path to autosavePath as path is the name of our import from the npm module path

@cmdcolin cmdcolin changed the title Bump deps Fix error launching session on desktop in v2.12.2 Jun 26, 2024
@cmdcolin cmdcolin merged commit be68f84 into main Jun 26, 2024
10 checks passed
@cmdcolin cmdcolin deleted the fix_path_error branch June 26, 2024 22:12
@cmdcolin
Copy link
Collaborator Author

might want to review how eslint didn't catch this perhaps...

@cmdcolin cmdcolin added the bug Something isn't working label Jun 27, 2024
@cmdcolin cmdcolin mentioned this pull request Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant