Skip to content

Conversation

@AfuroIsCrazy
Copy link

@AfuroIsCrazy AfuroIsCrazy commented Nov 29, 2025

Note

Refactors the offscreen Lattice flow to open the connector tab, validate/parse credentials, detect tab closure, and consistently return results/errors with cleanup.

  • Offscreen Lattice flow (app/offscreen/lattice.ts):
    • Tab Opening: Introduces openConnectorTab(url: string): Promise<Window> with improved error messaging.
    • Message Listener: Reworks init() to filter by OffscreenCommunicationTarget.latticeOffscreen, open the tab, and orchestrate response forwarding.
      • Validates postMessage origin/source/data against KnownOrigins.lattice and the opened tab.
      • Parses credentials JSON and enforces required fields (deviceID, password).
      • Detects user-closing of the connector via interval and returns an error.
      • Centralized cleanup (interval + event listener) and error serialization before sendResponse.
    • Types/Docs: Adds TypeScript typings and JSDoc annotations throughout.

Written by Cursor Bugbot for commit ddcb627. This will update automatically on new commits. Configure here.

@github-actions
Copy link
Contributor

CLA Signature Action:

Thank you for your submission, we really appreciate it. We ask that you read and sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just by adding a comment to this pull request with this exact sentence:

I have read the CLA Document and I hereby sign the CLA

By commenting with the above message you are agreeing to the terms of the CLA. Your account will be recorded as agreeing to our CLA so you don't need to sign it again for future contributions to this repository.

0 out of 1 committers have signed the CLA.
@AfuroIsCrazy

window.addEventListener('message', onMessageListener, false);
})
.catch((error) => {
// Handle tab opening failure (e.g., pop-up
Copy link

Choose a reason for hiding this comment

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

Bug: Missing return true breaks async sendResponse in Chrome

The Chrome extension message listener is missing return true; after the promise chain. When using sendResponse asynchronously (inside .then() or .catch() callbacks), the listener must return true synchronously to keep the message channel open. Without it, Chrome closes the channel immediately after the listener returns undefined, causing all sendResponse calls to silently fail. Other offscreen handlers in this codebase (like ledger.ts and trezor.ts) correctly include return true; with explanatory comments referencing the Chrome API docs. Additionally, the file appears to be truncated mid-catch block, leaving the code syntactically incomplete.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants