Make non-Dropbox Store callback consistently async#13
Draft
Copilot wants to merge 3 commits into
Draft
Conversation
Merged
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
There was a problem hiding this comment.
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 asetTimeoutclosure usingself(consistent withvar self = thisdefined at the top of the constructor) to make it asynchronous.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ox paths Agent-Logs-Url: https://github.com/Samuel3/LetterCreator/sessions/7e95f4f0-0078-4b18-bc4c-8d69f2f08250 Co-authored-by: Samuel3 <15921086+Samuel3@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The non-Dropbox path in
Storecalledcallback.call(this)synchronously, creating a timing hazard: callers assigning theStoreinstance to a variable used inside the callback could observeundefinedbefore the assignment completed.Change
Wrapped the non-Dropbox callback in
setTimeout(..., 0)to match the existing async behavior of the Dropbox path:💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.