Skip to content

Make non-Dropbox Store callback consistently async#13

Draft
Copilot wants to merge 3 commits into
masterfrom
copilot/sub-pr-5-59290d17-a801-46e7-8b97-a17fea663396
Draft

Make non-Dropbox Store callback consistently async#13
Copilot wants to merge 3 commits into
masterfrom
copilot/sub-pr-5-59290d17-a801-46e7-8b97-a17fea663396

Conversation

Copilot AI commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

The non-Dropbox path in Store called callback.call(this) synchronously, creating a timing hazard: callers assigning the Store instance to a variable used inside the callback could observe undefined before the assignment completed.

Change

Wrapped the non-Dropbox callback in setTimeout(..., 0) to match the existing async behavior of the Dropbox path:

// Before
} else if (callback) {
    callback.call(this);
}

// After
} else if (callback) {
    setTimeout(function () {
        callback.call(self);
    }, 0);
}

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: Samuel3 <15921086+Samuel3@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP on addressing feedback for add tests PR Make non-Dropbox Store callback consistently async Mar 2, 2026
@Samuel3 Samuel3 requested a review from Copilot March 2, 2026 19:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a timing hazard in Store.js where the non-Dropbox initialization path called the user-provided callback synchronously. Because callers (e.g., LetterStructure.js, Settings.js) reference the returned Store instance inside the callback, calling back synchronously meant that variable assignment (e.g., var store = new dataStore(...)) had not yet completed when the callback fired, potentially exposing undefined. The fix wraps the non-Dropbox callback in setTimeout(..., 0) to match the Dropbox path's existing async behavior.

Changes:

  • Wrapped the non-Dropbox callback.call(this) in a setTimeout closure using self (consistent with var self = this defined at the top of the constructor) to make it asynchronous.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/js/Store.js Outdated
Copilot AI requested a review from Samuel3 April 25, 2026 19:19
Base automatically changed from feature/add-tests to master June 1, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants