-
Notifications
You must be signed in to change notification settings - Fork 6
Add Drop Updates button to simulate transport failing to deliver messages #85
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
base: main
Are you sure you want to change the base?
Conversation
hpk42
left a comment
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.
lgtm
| on a specific instance. While enabled the instance will not recieve any updates | ||
| as if the transport has failed to deliver them. On | ||
| later reloads of the page the instance will load all updates as this state is | ||
| shared identically between all insances. |
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 think it is not clear enough that this is just a quirk of the current simulator implementation.
and some typos:
| on a specific instance. While enabled the instance will not recieve any updates | |
| as if the transport has failed to deliver them. On | |
| later reloads of the page the instance will load all updates as this state is | |
| shared identically between all insances. | |
| on a specific instance. While enabled the instance will not receive any updates | |
| as if the transport has failed to deliver them. On | |
| later reloads of the page the instance will load all updates as this state is | |
| shared identically between all instances. |
WofWca
left a comment
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 quite simple overall, and I like the idea. It's an important thing.
| const isAllowed = | ||
| event.origin.includes("localhost:") || | ||
| (location.host.endsWith(".webcontainer.io") && | ||
| event.origin.includes(".webcontainer.io")); | ||
| if (!isAllowed) { | ||
| return; | ||
| } |
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.
It would be nice not to copy-paste this code, especially if it's security-related
Lines 136 to 147 in f2d1f43
| window.addEventListener("message", (event) => { | |
| const isAllowed = | |
| event.origin.includes("localhost:") || | |
| (location.host.endsWith(".webcontainer.io") && | |
| event.origin.includes(".webcontainer.io")); | |
| if (!isAllowed) { | |
| return; | |
| } | |
| if (event.data === "reload") { | |
| window.location.reload(); | |
| } | |
| }); |
This toggles a dropUpdates value inside of the webxdc shim for a particular instance. When new updates come in they will be 'dropped' and not passed into the application. This lets you test what happens when certain devices miss a message!
This doesn't permanently modify the set of updates, so any app the replays them starting from the beginning will see the 'dropped' updates after being restarted. Doing this would require a refactor where we keep track of each instance's update set independently and to properly enumerate them over the websocket connection, probably not worth it for now.