-
Notifications
You must be signed in to change notification settings - Fork 4
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
don't retain port in content scripts #285
base: connection-lifecycle-branch
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commentary. possibly should minimize extra changes
import { createPenumbraStateEvent } from '@penumbra-zone/client/event'; | ||
import type { PenumbraProvider } from '@penumbra-zone/client/provider'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not strictly necessary, but due to poor webpack tree-shaking, importing from the root package apparently caused the generated script to be very large.
a more specific import significantly reduces the size of the content script.
disconnect: () => this.postDisconnectRequest(), | ||
isConnected: () => Boolean(this.port && this.presentState === PenumbraState.Connected), | ||
isConnected: () => this.presentState === PenumbraState.Connected, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would like to do some more investigation to identify possibly unknown problems with these changes to state transitions
private postDisconnectRequest() { | ||
const attempt = this.listenEndMessage(); | ||
window.postMessage(disconnectMessage, '/', []); | ||
return attempt; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pulled this out into its own method to match the structure of the connect request logic
if (this.presentState !== PenumbraState.Connected) { | ||
this.setPending(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change needs some closer inspection too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like the changeset primarily consolidated content scripts, removed global port object, and better message handling.
window.addEventListener('message', praxDocumentListener); | ||
chrome.runtime.onMessage.addListener(praxExtensionListener); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add code comments to the two event listeners, praxDocumentListener
and praxExtensionListener
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed base branch to connection-lifecycle-refactor
Content scripts no longer retain a
MessagePort
in violation of object transfer rules.Related to penumbra-zone/web#2018