Skip to content

Commit 4da2415

Browse files
committed
added invalid payload checks
1 parent 52d1b97 commit 4da2415

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

src/app/containers/ErrorContainer.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,31 @@ function ErrorContainer(props: ErrorContainerProps): JSX.Element {
1212

1313
// function that launches the main app and refreshes the page
1414
function launch(): void {
15-
dispatch(launchContentScript(tabs[currentTab]));
15+
// Add validation to ensure we have valid data
16+
if (!currentTab) {
17+
console.warn('No current tab available');
18+
return;
19+
}
20+
21+
if (!tabs || !tabs[currentTab]) {
22+
// If no tab data exists, create a minimal valid payload
23+
const defaultPayload = {
24+
status: {
25+
contentScriptLaunched: false,
26+
reactDevToolsInstalled: false,
27+
targetPageisaReactApp: false,
28+
},
29+
};
30+
dispatch(launchContentScript(defaultPayload));
31+
} else {
32+
dispatch(launchContentScript(tabs[currentTab]));
33+
}
34+
1635
// Allow the dispatch to complete before refreshing
1736
setTimeout(() => {
18-
chrome.tabs.reload(currentTab);
37+
if (currentTab) {
38+
chrome.tabs.reload(currentTab);
39+
}
1940
}, 100);
2041
}
2142

src/app/styles/components/_ax.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
padding: 8px 16px;
2121
font-size: 14px;
2222
font-weight: 500;
23-
color: var(--button-primary-text);
23+
color: var(--bg-primary);
2424
background-color: var(--color-primary);
2525
border-radius: 6px;
2626
cursor: pointer;

src/app/styles/layout/_stateContainer.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
overflow: auto;
161161
list-style: none;
162162
padding: 16px;
163-
margin: 0 0 50px;
163+
margin: 0;
164164
}
165165

166166
.tree-component {

src/extension/background.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,10 @@ chrome.runtime.onConnect.addListener(async (port) => {
391391
// (i.e. they're all related to the button actions on Reactime)
392392
port.onMessage.addListener(async (msg) => {
393393
const { action, payload, tabId } = msg;
394+
console.log(`Received message - Action: ${action}, Payload:`, payload);
395+
if (!payload && ['import', 'setPause', 'jumpToSnap'].includes(action)) {
396+
console.error(`Invalid payload received for action: ${action}`, new Error().stack);
397+
}
394398

395399
switch (action) {
396400
// import action comes through when the user uses the "upload" button on the front end to import an existing snapshot tree
@@ -708,7 +712,6 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
708712
payload: tabsObj,
709713
sourceTab,
710714
});
711-
console.log(`Sent snapshots to port at index ${index}`);
712715
} catch (error) {
713716
console.warn(`Failed to send snapshots to port at index ${index}:`, error);
714717
}

0 commit comments

Comments
 (0)