Fix verification and editor sync against current Chrome and Scratch - #38
Open
jasharpe wants to merge 1 commit into
Open
Fix verification and editor sync against current Chrome and Scratch#38jasharpe wants to merge 1 commit into
jasharpe wants to merge 1 commit into
Conversation
Two regressions from the platform moving under the extension made it silently do nothing: verification never completed, and no edit ever reached the server. Verification (background.js): the getUsername onMessage listener was `async`, so it returned a Promise for every message, and Chrome now delivers the resolved value (undefined) as the response, closing the channel before slower handlers like auth.js's `verify?` could reply. Neither branch awaits before calling sendResponse, so dropping `async` is safe. Editor sync (scripts/editor.js): several Blockly/scratch-blocks APIs no longer exist, and the first failure aborted activateLivescratch() before blockListener was registered. Republish window.Blockly from the trapped ScratchBlocks instance (the page's Blockly global lost getMainWorkspace()), and guard its call sites so they can't throw before the trap fires. Resolve the workspace via getMainWorkspace() and the dragged block via the current gesture, replacing the retired WorkspaceDB_, topBlocks_, and block drag surface (also dropping the now-dead getFlyout). Skip events flagged isUiEvent, whose 'drag' payload port.postMessage() cannot serialize. Anchor the revert button on any menu-bar button now that the "See Project Page" span is gone. Verified the API and DOM changes against the live scratch.mit.edu editor. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
jasharpe
force-pushed
the
fix/onmessage-async-listener
branch
from
August 24, 2026 02:26
cc82fa7 to
72868fe
Compare
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.
Two regressions from Scratch changes made the extension silently do nothing: verification never completed, and no edit ever reached the server.
Verification (background.js): the getUsername onMessage listener was
async, so it returned a Promise for every message, not just the ones it's supposed to handle. This means the slower handlers like auth.js'sverify?cannot reply and verification doesn't work. Neither branch awaits before calling sendResponse, so droppingasyncis safe.Editor sync (scripts/editor.js): Several Blockly/scratch-blocks APIs no longer exist, and the first failure aborted activateLivescratch() before blockListener was registered.
Fixes:
Verified by going into developer mode, loading the unpacked extension, and verifying that verification works and edits are now saved.
Claude was used to make the code changes in this PR. I don't have expertise in this area but wanted to fix the extension because it's currently broken.